$ sudo npm install npm -g
After updating npm this way I found there was a permissions problem with npm which I fixed with chmod:
$ sudo chmod +rx /usr/local/lib/node_modules
However, in light of the limitations described above, I started thinking about alternative options for programming with the BBB GPIO. Node-RED is a graphical tool designed for connecting Internet of Things devices, services and APIs, and uses a visual data-flow language similar to PureData or Max/MSP. There is a fork of bonescript called octalbonescript that has been updated to be compatible with Debian Jessie and which can be used with Node-RED to work with the GPIO pins. (Unfortunately it's not a drop-in replacement for bonescript or I'd be able to patch beaglebone-io to use it instead - but migrating the beaglebone-io library to use octalbonescript would be an interesting exercise).
I followed the instructions from the node-red beaglebone docs to install
node-red-node-beaglebone from npm, edit the settings file to enable octalbonescript, and then start the node-red server by running
node-red-pi (the version for memory limited environments). I recommend running it with the
-v command line flag so any errors will be printed to the console. It needs to be run as root to have permission to access the GPIO pins.
Once the server has started up, the web UI running on the BBB can be accessed via a Web Browser at http://192.168.7.2:1880/, and I was able to drag and drop the BBB-specific nodes that read from or write to the GPIO pins into a flow and deploy it and run the flow on the BBB:
One thing that wasn't obvious to me is that you need to double-click a node to pop up a dialogue where you can set properties like the pin number - the sidebar only dispays the current values and does not allow inline editing. I managed to crash the node-red server and had to edit the flows in /root/.node-red/flows_beaglebone.json to clear the nodes from the flow before it would restart.
(Reposted from element14 Music Tech blog)