Here are the steps to install an updated version of Node.js on Raspberry Pi. As of this writing, the Raspbian image from Feb 2016 is shipping Node.js vers 0.10.29 which was released in June 2014.
First remove the existing Node.js and npm that was installed with Raspbian:
sudo apt-get -y remove nodejs-legacy nodejs-dev nodejs sudo apt-get -y remove npm
In March 2016, this option installed v4.2.1 and can also be used to install v0.12.6.
There's a great site on installing Node.js on Raspberry here. First download the package. For the latest release issue this command:
For 0.12.6, download this:
sudo dpkg -i node_latest_armhf.deb
Check on the version of node you've just installed to confirm it's working:
If it can't find Node, then it's been installed in /usr/local/bin instead of /usr/bin. Make a symbolic link:
sudo ln -s /usr/local/bin/node /usr/bin/node
Install the express, http and json-proxy modules:
sudo npm install -g http sudo npm install -g express sudo npm install -g json-proxy
This option got me version 4.4.0 and is the approach documented on the Node Red site. Updating my apt-get cache resulted in some errors that required me to remove some additional source files in /etc/apt/sources.list.d/
curl -sL https://deb.nodesource.com/setup_4.x | sudo bash - sudo apt-get install -y build-essential python-dev python-rpi.gpio nodejs
Besides installing a newer version of node, this version also used /etc/alternatives to manage multiple Node installs.
wget https://nodejs.org/dist/latest-v4.x/node-v4.4.1-linux-armv7l.tar.gz tar -xvf node-v4.4.1-linux-armv7l.tar.gz cd node-v4.4.1-linux-armv7l.tar.gz sudo cp -R * /usr/local/