
Installing node on the Pi
There are many ways to install node on the Raspberry Pi, but the easiest one is using the Node Version Manager (nvm), which is an open source node installer and version manager.
First, install the curl command:
sudo apt-get update && sudo apt-get install curl
Then, install nvm via the install script:
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.1/install.sh | bash
The preceding command installs the latest version of nvm at the time of writing this. If you would like to install a later version, replace v0.33.1 in the URL with the latest version. Alternatively, you could see the complete installation command on nvms README page (https://github.com/creationix/nvm#install-script). Once nvm is installed, verify its installation by running this:
nvm --version
It should give you the version number that has been installed.
Now that we have VM installed, the next step is to install the desired version of node. You can see the active version of the node on the official website (https://nodejs.org). Currently, version 6 is the active version under Long Term Support (LTS) and is recommended for most users. To install this version, run the command:
nvm install 6
nvm should now automatically install the node on your machine along with npm. Verify that the node and npm are installed:
pi@raspberrypi:~ $ node -v
v6.10.2
pi@raspberrypi:~ $ npm -v
3.10.10
The second and third numbers for each version may be different depending on the date of installation, but if all else is well, then you have successfully installed the node on your Raspberry Pi.