By Petr Kout, September 13, 2016
I started fiddling with Node.js on Raspberry Pi because Node.js’ asynchronous event loop architecture makes it a great candidate for event based programming, such as controlling my Pi over Socket.io. I like the latest greatest Node.js version 6, though, and that one is not available in the Raspbian’s package manager as of now. But, of course, I can’t let that discourage me. Let’s install Node.js version 6 binary directly.
First, log into your Pi and find out what version of ARM architecture your Pi runs on:
You should see something like
Linux raspberrypi 4.4.11+ #888 Mon May 23 20:02:58 BST 2016 armv6l GNU/Linux
See the “armv61” part? That means that my Pi runs on ARMv6. Your Pi might run on a newer version, such as ARMv8.
Once you know your ARM version, open a browser and head over to the Node.js downloads page https://nodejs.org/en/download/current/ and scroll down to the “ARM Binaries” section. Right-click on the download that matches your architecture and copy the link to your clipboard.
Go back to your Pi’s shell and download the file, e.g.:
Once the download finishes, unzip the package and copy the relevant folders over to your /usr/local directory:
tar -xvf node-v6.5.0-linux-armv6l.tar.xz cd node-v6.5.0-linux-armv6l sudo cp -R bin/ /usr/local/ sudo cp -R include /usr/local/ sudo cp -R lib/ /usr/local/ sudo cp -R share/ /usr/local/
Okay, almost done. Clean up after yourself and check that you have the version 6 of Node.js installed:
cd .. rm node-v6.5.0-linux-armv6l.tar.xz rm -rf node-v6.5.0-linux-armv6l node --version
The last command should output something like: v6.5.0
You’re set. Enjoy Node.js on your Pi!