Archives About

Setting up node.js on the Raspberry Pi

So you wanna write JavaScript and run it on your Pi, huh?

Cool, me too, I’ve been setting up a Raspberry Pi so that I can hack something together quickly using JavaScript. …but it looks like Raspbian doesn’t have a package for node.js in any of the repositories that apt pulls from. Nevertheless, it’s still quite simple to get going with node.js on the Pi.

Node.js distributes pre-compiled binaries that target the ARMv7 architecture and these can be found on the node.js download page (Linux > ARM > ARMv7).

We can fetch the prebuilt archive, extract it, and move the resulting files to /usr/local and we’ll be in business.

Just a heads up that I’m using $URL as a placeholder below so you don’t install an old version of node when you stumble onto this tutorial.

You can either set it before executing the commands below:


…or simply replace $URL with the URL of the archive found on the downloads page.

# you'll need to be a super-user for writing to /usr/local
sudo -i

# fetch the archive and extract it to the current directory
curl -s $URL | tar xJf -

# move executables and libraries to respective /usr/local location
cp -R node-*/* /usr/local

# remove the directory created during extraction
rm -rf node-*

# drop back out of the superuser shell

If all works correctly, you should see both node.js and npm in your path.

which node && which npm

Written on Dec 3, 2018.