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- 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
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. Hope this guide help you in installation of node in ubuntu environment.
How to install Node.js on Ubuntu 16.04/18.04 using NVM (Node Version Manager) was originally published in Hacker Noon on Medium, where people are continuing the conversation by highlighting and responding to this story.