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

Posted by

NVM is basically the version manager for Node.js. With the help of NVM we can install and use multiple versions of Node.js along with NPM. If we have multiple Node.js projects having various versions of node and npm then always install node using NVM only.

Installation of NVM

First download the NVM installation script using cURL as follows

$ curl -o- | bash

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

To reflect the changes for the current user session, use the following command
$ source ~/.profile

Check installed NVM version as follows:
$ nvm --version

Use the following nvm command to list all available node.js versions:
$ nvm ls-remote

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:
$ nvm list

To use particular node version use
$ nvm use 10.15 # it will use node 10.15.0

To check node and npm version, use the following commands:
$ node -v
$ npm -v


Now successfully installed the Node.js and npm using NVM. It will be very useful to manage the various nodejs projects having different node versions. I hope this guide helps you in the installation of node in ubuntu environment.