How to install Node.js on Ubuntu 16.04/18.04 using NVM (Node Version Manager)

Installation of NVM

First download the NVM installation script using cURL as follows

$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash

After downloading the script, run the script using bash as follows

$ bash install_nvm.sh

To reflect the changes for the current user session, use following command

$ source ~/.profile

Check installed NVM version as follows

$ nvm --version

Use following nvm command to list all available node.js versions

$ nvm ls-remote

It shows the output as follows

Install particular node version using following nvm command:

$ nvm install 10.15 # it will install node 10.15.0

To see all installed node version, use nvm list as follows:

To use particular node version use

$ nvm use 10.15 # it will use node 10.15.0

To check node and npm version, use following commands:

$ node -v
$ npm -v

read original article here