So, now that our Raspbian OS is installed and set up, it's time to install Node.js (which comes bundled with npm), Johnny-Five, and Raspi-IO!
Installing Node.js, Johnny-Five, and Raspi-IO
Installing Node.js and npm
In days past, you would have to compile the Node.js source on your Pi, to varying degrees of success because of the nonexistence of binaries for the ARM processor that Raspberry Pi uses. Luckily now, because of a rousing amount of third-party support in the past few years, you can easily download the binary from the https://nodejs.org/en/ website! But how are we going to do this from the command line of our Raspberry Pi?Â
Detecting your version of ARM processor
If you're using the Raspberry Pi 3 Model B recommended by this book, you're most likely on ARM v8 (the Raspberry Pi 3 original is ARMv7, which is fine too!). But you should always double-check (doubly so if you're using a different Raspberry Pi, such as the Pi Zero or Pi 2/1 series). To check the ARM version on your Raspberry Pi, run the following in your SSH Terminal:
uname -m
You'll see a return message that looks like armv#, where # is a number (possibly followed by a letter). That number is what is important, because that number tells us which Node.js binary we will need. Once you have your ARM version, go through the following steps:
- Head to the Node.js download page at https://nodejs.org/en/download/, as shown in the following screenshot:

- Right-click on the ARM version link you need and copy the URL. Then, run the following in your Raspberry Pi's SSH Terminal:
wget <binary-download-url>
Replace <binary-download-url> (carats, too!) with the URL you copied from the Node.js download website. Once it's downloaded, we need to extract the archive using the following code:
tar -xvf node-v****-linux-armv**.tar.xz
- The asterisks will differ depending on the current LTS version of Node.js and your ARM version. The Raspberry Pi will spit out a lot of filenames to the console, then give you back your shell prompt. This means that the binaries have been extracted into your home folder. We need to place them into the /usr/local folder. To do that, run the following:
cd node-v****-linux-armv**
sudo mv ./lib/* /usr/local/lib
sudo mv ./share/* /usr/local/share
- This will move all of the precompiled binaries to their new homes on your Raspberry Pi. Once this is done, run the following:
node -v
npm -v
You should see something like the following:

- If that's all well and good, you now have Node.js and npm installed! Let's wrap this up with Johnny-Five and Raspi-IO! Note that you can absolutely clean up the binary downloads by running the following:
cd ~
rm -rf node-v**-linux-armv**
rm -rf node-v****-linux-armv**.tar.xz
Installing Johnny-Five and Raspi-IO
To install Johnny-Five, once you've made sure Node.js and npm are installed, run the following command:
npm i -g johnny-five raspi-io
This installs the libraries globally; you won't have to reinstall it every new project. And that's it! You're ready to start developing Node.js robotics projects on the Raspberry Pi with Johnny-Five!