We have discussed how to install NodeJS on Ubuntu systems in our earlier tutorial, but that way we can only use a single installed version of nodejs on our system. What if we want to use another nodejs version, then what should we do ??

We can install NVM on the Ubuntu system. NVM stands for Node Version Manager is used for managing multiple versions of nodejs on a single system by controlling the nodejs versions installed on the system, also it can be used to install nodejs on the system. Basically, it is a command-line utility that allows us to switch between installed multiple nodejs versions.

Recommended Read: Simple way to install ADB & FastBoot on Ubuntu

Also Read: Install SNAP on Ubuntu & CentOS/RHEL

Currently, it supports Linux & MAC operating systems & doesn’t support Windows but there are some 3rd party tools for Windows that can be used for the same purpose. To install NVM on the Ubuntu system, we can use an install script maintained on GitHub. This will install NVM on Ubuntu as well as CentOS/RHEL/Debian systems as well. So let’s discuss the installation procedure for the same.


Install NVM on Ubuntu


First, we need to download the latest install script for NVM, use the following command to download the latest script from Github,

$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash

This command will not only download the script but will execute it as well. Once the script finishes, we can either close terminal & open a new session or we can source the ‘~/.bash_profile’ as some new paths for NVM would be added.

$ source ~/.bashrc


Manage NodeJS versions

Once we have nvm installed on our system, we can check the following commands to manage the installed nodejs versions.

1- List all available

To get the list of all available versions that can be installed our system, we will use the following command,

$ nvm list-remote

We will then get list of all the available versions with complete version numbers.


2- Install nodeJs version

To install a nodejs version, we can copy the version number that we got from the above-mentioned command & to install it use,

$ nvm install v0.12.18

We will then install another version also,

$ nvm install v8.1.3


3- List all installed NodeJs versions on the system

To get the list of all the nodejs versions installed on our system, we can use the following command,

$ nvm list


4- Set default nodejs version

To set a default nodejs version for the system, execute the following command,

$ nvm alias v8.1.3


5- Switch to different NodeJs version

To switch to another installed nodejs version, the command is

$ nvm use v0.12.18


6- Uninstall an installed NodeJS version

To uninstall an installed nodejs version, execute the following command,

$ nvm uninstall v8.1.3

This completes our tutorial on how to install NVM on Ubuntu & use it to manage the multiple nodejs versions on a single system. Please do let us know, if you face any issues or have questions, you can contact us using the comment box below.

If you think we have helped you or just want to support us, please consider these:-

Connect to us: Facebook | Twitter | Linkedin

TheLinuxGURUS are thankful for your continued support.