Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Working Node.js on Raspberry Pi

These instructions work for the Raspberry Pi running Raspbian (hard float) and create a hardware optimized version of NodeJS for the Raspberry PI, (and include a working install and NPM!!!):

  1. Install Raspbian - http://www.raspberrypi.org/downloads

  2. Install the necessary dependecies:

sudo apt-get install git-core build-essential

(If you just installed git then you need to administer your git identity first, else adding the patches below will fail!!!)

  1. Check out Node.js source (0.8.8 or higher):
git clone https://github.com/joyent/node.git
cd node
git checkout v0.8.8 -b v0.8.8
  1. Push four patches for V8 and OpenSSL ARM support:

The following two patches are only needed when compiling Node version <0.8.10 (already committed for 0.8.10pre NOT yet for master)

Remark: The first patch is already commited upstream to V8 cutting-edge branch (node is on a lower version of V8). The 2nd patch is pushed to the V8 bug list.

curl https://github.com/joyent/node/commit/25c2940a08453ec206268f5e86cc520b06194d88.patch | git am
curl https://github.com/joyent/node/commit/1d52968d1dbd04053356d62dc0804bcc68deed8a.patch | git am

The following two patches are only needed when compiling Node version <0.8.9 (already committed for master and 0.8.9pre + higher)

curl https://github.com/joyent/node/commit/f8fd9aca8bd01fa7226e1abe75a5bcf903f287ab.patch | git am
curl https://github.com/joyent/node/commit/7142b260c6c299fc9697e6554620be47a6f622a9.patch | git am
  1. Configure correctly and 'make':
./configure
make
  1. (Optional!) If you want to do the tests then execute (make test can't be used because the standard timeout is too low, i.e. the Rasp PI is too slow... ;-)):
python tools/test.py -t 120 --mode=release simple message
  1. Install Node and NPM in your OS:
sudo make install

NOTE on 0.8.8 tests: some tests still have issues (8 tests fail, some are timeouts (as the PI isn't that fast ;-) and one is a known bug)!

After compiling node0.8.8 the following 7 (or 8 if IPV6 is not enabled) tests will fail. After checking 3 failing tests are related to the slow processing/slow filesystems, 1 is a known bug and 3 (repl problems) are under investigation.

The following is a known bug. Will be solved in one of the next releases of Node (see joyent/libuv#526).

=== release test-os ===
Path: simple/test-os
hostname = raspberrypi
uptime = 19738.871849515
Command: out/Release/node /home/pi/node0.8.6/test/simple/test-os.js

The Rasp Pi is not that fast that it can complete the following test in time. ;-) If time is changed from 1000 to 10000 it will complete without error...

=== release test-child-process-fork-net2 ===
Path: simple/test-child-process-fork-net2
assert.js:102
  throw new assert.AssertionError({
        ^
AssertionError: timeElasped was not between 190 and 1000 ms
    at process.<anonymous> (/home/pi/node0.8.6/test/simple/test-child-process-fork-net2.js:128:12)
    at process.EventEmitter.emit (events.js:115:20)
Command: out/Release/node /home/pi/node0.8.6/test/simple/test-child-process-fork-net2.js

Raspbian doesn't have IPv6 enabled by default and thats where this following test is counting on. if IPv6 is enabled (sudo modprobe ipv6) this test will complete without errors.

=== release test-net-pingpong ===
Path: simple/test-net-pingpong
server listening on /home/pi/node0.8.6/test/tmp/test.sock undefined
server listening on 20988 undefined
connection: 127.0.0.1
connection: undefined
events.js:66
        throw arguments[1]; // Unhandled 'error' event
                       ^
Error: listen EAFNOSUPPORT
    at errnoException (net.js:768:11)
    at Server._listen2 (net.js:891:19)
    at listen (net.js:935:10)
    at Server.listen (net.js:992:9)
    at dns.js:71:18
    at process.startup.processNextTick.process._tickCallback (node.js:244:9)
Command: out/Release/node /home/pi/node0.8.6/test/simple/test-net-pingpong.js

The Rasp Pi is not that fast that it can complete the following test in time. ;-) If timeouts are changed from 10 to 100 and 20 to 200 it will complete without error...

=== release test-http-client-timeout-with-data ===
Path: simple/test-http-client-timeout-with-data
assert.js:102
  throw new assert.AssertionError({
        ^
AssertionError: 0 == 1
    at process.<anonymous> (/home/pi/node0.8.6/test/simple/test-http-client-timeout-with-data.js:30:10)
    at process.EventEmitter.emit (events.js:115:20)
Command: out/Release/node /home/pi/node0.8.6/test/simple/test-http-client-timeout-with-data.js

The Rasp Pi is not that fast that it can complete the following test in time. ;-) If run seperately this test will complete without error!!!

=== release test-eio-race ===
Path: simple/test-eio-race
trying to kill event loop ...
could not kill event loop, retrying...
Command: out/Release/node /home/pi/node0.8.6/test/simple/test-eio-race.js
--- TIMEOUT ---

All the following REPL test fail are under investigation (possibly due to timing issues generated by the slow processing of the Rasp PI).

=== release test-debugger-repl ===
Path: simple/test-debugger-repl
./node debug --port=13683 /home/pi/node0.8.6/test/fixtures/breakpoints.js
line> debug>< debugger listening on port 13683
line> debug>connecting... ok
line> debug>break in test/fixtures/breakpoints.js:1
line>  1 debugger;
line>  2 function a(x) {
line>  3   var i = 10;
line> debug>break in test/fixtures/breakpoints.js:11
Error: Timeout. Expected: /9/
Command: out/Release/node /home/pi/node0.8.6/test/simple/test-debugger-repl.js
=== release test-force-repl ===
Path: simple/test-force-repl
timers.js:103
            if (!process.listeners('uncaughtException').length) throw e;
                                                                      ^
Error: timeout!
    at Object._onTimeout (/home/pi/node0.8.6/test/simple/test-force-repl.js:30:9)
    at Timer.list.ontimeout (timers.js:101:19)
Command: out/Release/node /home/pi/node0.8.6/test/simple/test-force-repl.js
=== release test-debugger-repl-utf8 ===
Path: simple/test-debugger-repl-utf8
./node debug --port=13683 /home/pi/node0.8.6/test/fixtures/breakpoints_utf8.js
line> debug>< debugger listening on port 13683
line> debug>connecting... ok
dying badly
Error: Timeout. Expected: /break in .*:1/
Command: out/Release/node /home/pi/node0.8.6/test/simple/test-debugger-repl-utf8.js
@leommoore
Copy link

leommoore commented Feb 5, 2013

Thanks Sander, that worked a treat on my pi

@shaunfreeman
Copy link

shaunfreeman commented Apr 3, 2013

Thanks mate, worked first time. Nice post

@d0nd3r3k
Copy link

d0nd3r3k commented May 14, 2013

Install it in 5 min, no need to compile no more :)

wget http://nodejs.org/dist/v0.10.2/node-v0.10.2-linux-arm-pi.tar.gz
tar xvzf node-v0.10.2-linux-arm-pi.tar.gz

you only need to add it to your path variables here:

nano /etc/profile

Check https://github.com/DonaldDerek/rPi-cheat-sheet for more info..

@antonywu
Copy link

antonywu commented Jul 27, 2013

@DonaldDerek, thanks!

I didn't have to add any path. I only had to symbolic link node and npm to be under /usr/bin
sudo ln -s ./node-v0.10.2-linux-arm-pi/bin/node /usr/bin/node sudo ln -s ./node-v0.10.2-linux-arm-pi/bin/npm /usr/bin/npm

@sgerrand
Copy link

sgerrand commented Jan 9, 2015

@DonaldDerek et al who come here in search of a ARM binary:

For whatever reason, there is no longer an ARM binary available on the node.js distribution site. 😾

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment