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.
NVM Installation & usage on Windows. Below are the steps for NVM Installation on Windows: NVM stands for node version manager, which will help to switch the your node versions for specific use. It also allows the user to work with multiple npm and node versions. Install nvm setup. Use command 'nvm list' to check list ofinstalled node version. Nvm is a popular way to run Node.js. It allows you to easily switch the Node.js version, and install new versions to try and easily rollback if something breaks, for example. It allows you to easily switch the Node.js version, and install new versions to try and easily rollback if something breaks, for example.
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.
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.
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:
Note that in the above command, “node” is an alias for the latest version.
Install Latest Node Version in Linux
To install a specific “node” version, first list the available node versions and then install the version as shown.
You can check all installed version with the following command:
List Installed Node Versions in Linux
You can use a node.js version in any new shell as shown:
Alternatively, simply run a node version as shown (to exit, press
^C
).Run Node Version in Linux
Importantly, you can view the path to the executable to where a specific node version was installed as follows:
Furthermore, to manually set a default node version to be used in any new shell, use the alias “default” as shown.
Set Default Node Version in Linux
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.
Share