Installing node.js on the Raspberry Pi Archlinux
All activity and commands in this tutorial are run on the Raspberry Pi, either via SSH or physical keyboard. It is possible to cross-compile on your laptop/desktop for ARM, but I preferred not to in this case.
base-devel group installed, you should have a working
gcc and friends, along with
zlib. Also install
Get the source
I usually stay on node bleeding edge so:
$ git clone git://github.com/joyent/node
Since Archlinux uses python3 by default, the configure and build scripts screw up. You can edit the individual files, but I find it easier to just use virtualenv, which will setup the shell environment to use python2 and its libraries.
$ virtualenv2 env
$ source env/bin/activate
env is the name of the directory virtualenv will use to store scripts. You can use some other name. Sourcing the
activate script will set up the environment so that
python will actually be
Patch the source
Geoff Flarity has created a patch to tweak the build parameters a bit. You can either follow the instructions to apply the patch, or just comment the 12
vfp3:on... lines yourself, which is what I did. Also set the environment variables to build for ARM as in the README.
NOTE: All commands should be run in the same shell that has the virtualenv environment and the above variables set.
Use system zlib and openssl
Attempting to compile the included openssl failed on my Archlinux setup with some ARM assembly errors. Using the installed libs will also reduce the compilation time. So
$ ./configure --shared-openssl\
$ su -c 'make install'
The build will take some time (30 minutes to an hour), so be patient. Once it is done you will have a fully working node runtime on your Raspberry Pi. Use it to power your home automation control server or whatever else. I use it to experiment with my DHT implementation.
The use of node.js to write low-level systems services or networking code over traditional languages like C/C++ is very interesting, because it provides a safer, garbage-collected runtime, with efficient I/O and a less verbose language. Inexpensive devices like the Raspberry Pi allow experimenting with multiple devices or peer-to-peer configurations rather than being bound to only localhost testing for those on a tight budget. So get a Pi and have fun.