NVM – Install and Manage Multiple Node.js Versions in Linux

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.

Install Node Version Manager in Linux

Install Node Version Manager in Linux

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.

Node Version Manager in Linux

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.

# nvm ls-remote
# nvm install 10.15.3  	#or 8.16.0, 11.15.0 etc
Install Specific Node Version in Linux

Install Specific Node Version in Linux

You can check all installed version with the following command:

# nvm ls
List Installed Node Versions in Linux

List Installed Node Versions in Linux

You can use a node.js version in any new shell as shown:

# nvm use node	#use default
OR
# nvm use 10.15.3
Use Specific Node Version in Linux

Use Specific Node Version in Linux

Alternatively, simply run a node version as shown (to exit, press ^C).

# nvm use node	#use default
OR
# nvm use 10.15.3
Run Node Version in Linux

Run Node Version in Linux

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
Get Node Installed Location

Get Node Installed Location

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
Set Default Node Version in Linux

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.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

Aaron Kili

Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

1 Response

  1. José says:

    You don’t need to be root or sudo ( # ) to do this

Got something to say? Join the discussion.

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.