Introduction
Hi Techies! Today we will learn about “How to Download and Install Node Version Manager (NVM) in Ubuntu”. Using Node Version Manager you can have as many versions for Node.js in a single system with a particular user.
So NVM can install by many users on the same system without any issues or the versions conflicts. We can have the latest, stable version with the help of the node version manager. You can switch the versions as per your need.
So by following the below steps we can manage the NodeJS with the node version manager command(NVM).
- How to download and Install the Node Version Manager Script.
- Install the Node Js with Node Version Manager in Ubuntu.
- Install the different versions of Node.js.
- How to Switch the versions of Node.js with the help of the nvm command.
How to download and Install the Node Version Manager Script.
So let’s download the script for NVM by using the curl command. And to install the curl command in the ubuntu system use the below command.
In Ubuntu/Debian/Linux Mint.
$ sudo apt install curl
After downloading the script for NVM in Ubuntu. Run the script using “| bash” after the curl command and URL.
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash

$ source ~/.bashrc
Once we reload the “.bashrc” file, then we have to install NodeJS in Ubuntu.
If you want to use the latest version or the source code there is a GitHub repo link please refer to that.
How to list the NodeJS versions using NVM command.
To list the version available for the Node Js you can use the command “nvm list-remote”. This will show you all the stable and the latest version for the Node Js.
$ nvm list-remote OUTPUT: v14.17.5 (LTS: Fermium) v14.17.6 (Latest LTS: Fermium) v15.0.0 v15.0.1 v15.1.0 v15.2.0 v15.2.1 v15.3.0 v15.4.0 v15.5.0 v15.5.1 v15.6.0 v15.7.0 v15.8.0 v15.9.0 v15.10.0 v15.11.0 v15.12.0 v15.13.0 v15.14.0 v16.0.0 v16.1.0 v16.2.0 v16.3.0 v16.4.0 v16.4.1 v16.4.2 v16.5.0 v16.6.0 v16.6.1 v16.6.2 v16.7.0 v16.8.0
So we have listed the versions. Now it depends on us, which version is best suits to your project, or you want to install the stable version.
Install the NodeJS with NVM command in Ubuntu.
Let’s suppose we have to install the Stable LTS version of Node Js 14.17.6 using NVM in Ubuntu.
$ nvm install v14.17.6

So after done with the installation, we will list the NVM(Node Version Manager) to check the installed version for Node.js.
$ nvm list
Also, we can check the versions with node and npm commands on the command line.
$ node -v
$ npm -v
How to Install different versions of Node.js using the NVM command.
So now let’s install the 16.6.2 version of Node.js using NVM(Node Version Manager) in Ubuntu.
$ nvm install v16.6.2

So we have installed node 16 versions with 7.20 of an NPM. Let’s check the version for a Node.js

$ nvm list
So we can see both versions now currently, NodeJS version 16 is active. Same we can check with the node and npm command.
$ node -v
$ npm -v
How to Switch the versions of Node.js using NVM
Let’s see how to switch the node.js version using the nvm command on the terminal. We can downgrade or upgrade the version for the NodeJS with the help of nvm(Node Version Manager) command.
$ nvm use v14.17.6

We have switched versions 16 to 14 in ubuntu using the nvm command, let’s check the active version on the system. Also, we can check the versions with the node and npm command.
$ node -v
$ npm -v
Conclusion
So in this article, we have looked at “How to download the script for the Node Version Manager (NVM)”. We have installed the script for Node Version Manager. Then we have listed the versions for the NodeJS using the “nvm list-remote” command. Finally, we have installed the NodeJS and switched the NodeJS versions. NVM, the command is very helpful to manage the many NodeJS versions on the same machine or the server.
If you want to Install NodeJS and NPM without the NVM in Ubuntu 20. If you want to install PM2 on Linux. 2 ways to Upgrade or Update the NodeJS version in Ubuntu. Any issues or feedback please let us know in the comment section..