Node Version Manager (NVM in short) is a simple bash script to manage multiple active node.js versions on your Linux system. It allows you to install multiple node.js versions, view all versions available for installation and all installed versions on your system.
Nvm also supports running of a specific node.js version and it can show the path to the executable to where it was installed, and much more.
Read Also: 14 Best NodeJS Frameworks for Developers in 2019
In this article, we will explain how to install Node Version Manager (NVM) to manage multiple active node.js versions on your Linux distribution.
Installing Node Version Manager in Linux
To install or update nvm on your Linux distribution, you can download the auto-install script using curl or wget command line tools as shown.
# curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash OR # wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
The above auto-install script clones the nvm repository to ~/.nvm
in your home directory and adds the required source commands to your shell startup scripts i.e ~/.bash_profile, ~/.zshrc, ~/.profile, or ~/.bashrc, depending on the shell program you are using as shown in the following screenshot.

Next, verify if the nvm has been installed on your system using the following command.
# command -v nvm nvm
It will show output as ‘nvm‘ if the installation was successful.
How to Use Node Version Manager in Linux
Now it is time to learn how to use Node Version Manager in Linux.
To download, compile, and install the latest release of node, run the following command:
# nvm install node
Note that in the above command, “node” is an alias for the latest version.

To install a specific “node” version, first list the available node versions and then install the version as shown.
# nvm ls-remote # nvm install 10.15.3 #or 8.16.0, 11.15.0 etc

You can check all installed version with the following command:
# nvm ls

You can use a node.js version in any new shell as shown:
# nvm use node #use default OR # nvm use 10.15.3

Alternatively, simply run a node version as shown (to exit, press ^C
).
# nvm use node #use default OR # nvm use 10.15.3

Importantly, you can view the path to the executable to where a specific node version was installed as follows:
# nvm which 10.15.3 # nvm which 12.2.0 # nvm which system #check system-installed version of a node using “system” alias

Furthermore, to manually set a default node version to be used in any new shell, use the alias “default” as shown.
# nvm alias default 10.15.3 # nvm alias default system # nvm alias default 12.2.0

Note: You can create a .nvmrc
initialization file in your project root directory (or any parent directory) and add a node version number or any other flags or usage options that nvm understands, in it. Then use some of the commands we have just looked at above to operate with the specified version in the file.
For more information, see nvm --help
or go to the Node Version Manager Github repository: https://github.com/nvm-sh/nvm.
That’s all! Node Version Manager is a simple bash script to manage multiple active node.js versions on your Linux system. Use the feedback form below to ask questions or share your comments with us.
You don’t need to be root or sudo ( # ) to do this