How to install NVM and node.js on Raspberry Pi
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- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
The script clones the nvm repository to ~/.nvm and adds the source line to your profile (~/.bash_profile, ~/.zshrc, ~/.profile, or ~/.bashrc).
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # 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: