Since i am a big fan of Node.js and wanted to use the latest version on my Raspberry, i´ll explain how to install it in this article. We´ll take the pro route this time and compile Node.js on our own, because we want the latest Node.js version and they are not very fast with the ARM builds. And because it´s cool.
Btw, this works with the Raspberry Pi 2, but NOT with the old one. Afaik you need to include a fix to make it work for the old one, but i don´t really want to change the source files and all the cool kids are using a Raspberry Pi 2 nowadays.
Downloading the source
Fasten your seatbelt, it´s time for some action! Open the dist folder in your browser to check out the latest version: http://nodejs.org/dist/
As of now, this would be v0.12.0, so open a SSH session to your Raspberry Pi and use the following commands:
tar xvzf node-v0.12.0.tar.gz
This will download and extract the latest sources, and you will end up in the source folder.
Next on the list is the compiling process. It will take quite some time but you can speed it up a bit by overclocking the Raspberry Pi, of course. Anyway, here´s how to start it:
make -j 4
The parameter is very important, if you omit “-j 4” it will only use one core. And the Raspberry Pi 2 comes with 4 of them, so make sure to use them! It should not take longer than 30min with all cores.
After the compiling process, use the following command to install the binaries:
sudo make install
The install location will be /usr/local/bin, so you can use node/npm from any directory after that.
Testing the installation
You can easily test the installation by checking out the version of Node.js, npm should be working too:
If the version shows up, you´re ready to start programming wonderful stuff with Node.js. You can also try the basic example from nodejs.org.
Of course you can just delete the sources now, to keep your Raspberry Pi clean. But you should already know how to do that from my article about Linux Basics.
Edit: This may not be neccessary anymore, they now offer a build for ARM even for the latest version: http://nodejs.org/dist/latest/