NodeJS on Raspberry Pi

Install latest version of NodeJS on Raspberry Pi

Installing NodeJS on a Raspberry Pi used to be something difficult. However it's really straightforward and easy to do these days by downloading a pre-compiled archive from the NodeJS archives.

Just make a script called install-nodejs.sh on your Raspberry Pi and paste the following contents in it. At the time of writing the latest available version of NodeJS is 10.8.0, change the VERSION variable to whatever version you like.

#!/usr/bin/env bash

VERSION=10.8.0
ARCH=armv6l

wget https://nodejs.org/dist/v$VERSION/node-v$VERSION-linux-$ARCH.tar.gz
tar xf node-v$VERSION-linux-$ARCH.tar.gz
rm -f node-v$VERSION-linux-$ARCH/*
pushd node-v$VERSION-linux-$ARCH/
sudo cp -R * /usr/local/
popd
rm -rf node-v$VERSION-linux-$ARCH
rm node-v$VERSION-linux-$ARCH.tar.gz

Now make the script executable using chmod +x ./install-nodejs.sh and execute it afterwards using ./install-nodejs.sh. After it finished you should have your desired NodeJS version installed.

You can verify this by running node --version. Enjoy 🍻!