How to install NVM and node.js on Raspberry Pi

Node Version Manager (NVM) is a tool that allows you to install versions for node.js. A number of our examples use node.js so you may need to install node before you can run our JavaScript examples. 

The full version of Raspberry Pi Raspbian comes with node.js pre-installed but if you chose to install the light version than you will need to follow these steps to install node.js.

To install or update nvm, use the install script using cURL:

curl -o- | bash

The script clones the nvm repository to ~/.nvm and adds the source line to your profile (~/.bash_profile, ~/.zshrc, ~/.profile, or ~/.bashrc).

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/" ] && \. "$NVM_DIR/" # This loads nvm

Now check if the nvm is installed by typing:

command -v nvm

The above command should return "nvm"

Now install the latest stable version of node.js by typing:

nvm install stable

Now type the following to see the version you have just installed:

node -v