HomeTutorialsHow To Install Node Version Manager Tool - NVM on Linux System

How To Install Node Version Manager Tool – NVM on Linux System

NVM is a cross-platform node version manager that can maintain a different version of nodes on your Linux system. Now, if you are familiar with working with Node.js, you might already know that there are plenty of versions of Node.js are available. NVM works with the help of the source-code of NodeJS and the Chrome V8 engine. The engineers of Google build the chrome V8 engine, and they made a collaboration with the NVM to offer the users a smooth and reliable user interface. You can install this tool on your Linux distribution to reduce the memory issue, to upgrade the Node.js file automatically on your system.

NVM on Linux


As the Node.js developers are working hard to make it more perfect, they release many versions of NVM now and then. Now, as a developer, you know that setting up an environment kills a lot of potential time. Here comes the NVM; it can automatically upgrade your NVM on the Linux system without losing any script, files, and documents. In this post, we will see how you can install and get started with this tool on your Linux system.

1. Install NVM on Ubuntu Linux


Installing the NVM on Debian and Ubuntu Linux is not a complex task. You need to download the NVM installation bash files from the GitHub repository; then, you need to run the bash script to install it on your Ubuntu system. You can follow this link to visit the GitHub repository of NVM.

Now, we will use the cURL command tool to fetch the installation data inside our Linux filesystem. If you don’t have the CURL installed inside your machine, you need to install cURL on your system. You can use the following terminal command-lines given below to get the bash file of NVM on our Debian/Ubuntu Linux.

sudo apt install curl 
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash

install NVM on ubuntu CURL

Now, run the following command on your terminal shell to fetch the data.

source ~/.profile

Finally, you can now run the following NVM command given below to install the latest node version manager in your Linux system.

nvm install node

After the installation is done, you can check the current NVM version to ensure that the NVM is installed correctly on your Linux system. You can also install any other versions of NVM inside your system.

install NVM on ubuntu Linux ls default

2. Install Node Version Manager on Fedora/CentOS Linux


If you are a Fedora, Red Hat, or CentOS Linux user, you can follow the steps that I will demonstrate now. The method of installing the NVM on Fedora Linux includes two steps. You can follow them chronologically.

I must mention that I am using Fedora Linux to represent the entire Red Hat-based Linux distributions. You can change the DNF command to the YUM command according to the requirement of your distribution.

Step 1: Install NPM on Fedora Linux


In this step, we will use the basic DNF commands to download and install the NVM on our Fedora Linux. First, you have to install the NodeJS runtime and the NPM tool on your Linux system to run the NPM commands to install the NVM on our system.

NPM mainly handles the javascript and the NodeJS scripts. Run the following DNF command given below to install the NPM and NodeJS tool. The following command will install the latest version of NPM on your system.

sudo dnf install -y nodejs npm

NVM on Fedora Linux nodejs

You can also install any other global versions of NPM on your Linux system by running some command-lines on your terminal shell. Let you want to install the version of NPM; in that case, we will run the following command-line given below.

sudo npm install -g n

Now, if necessary, you can run the following command-lines given below to switch between the versions of NPM on your system. In my case, I have Node 6.0.0 installed inside the system.

sudo ln -sf /usr/local/n/versions/node/6.0.0/bin/node /usr/bin/node
ln -s /usr/bin/nodejs /usr/bin/node

Step 2: Install NVM via the NPM Tool


As we have installed the node version manager tool on our Fedora Linux, we will now install the NVM tool via the NPM commands. Run the following command-lines given below to install the NVM tool on your Linux system. First, install the cURL on your Linux system. Then use the cURL tool to download the bash script of NVM on your Fedora Linux.

sudo dnf install curl 
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash

NVM on Fedora Linux CURL

Then, run the following bashrc command to fetch the script on your system.

source ~/.bashrc

Finally, you can now install the NVM tool on your system by running the following command-line given below.

nvm install node

You can also choose any different versions of the NVM tool to install on your Linux system.

nvm install 12.8.3

3. Install Node Version Manager on Arch Linux


There are two available methods to install the node version manager (NVM) on the Arch and the Arch-based Linux system. In the first method, we will see how you can directly install the NVM tool on your Arch Linux. In the second method, we will use the default Pacman commands to install the NVM tool on our Arch system. Here, I am using the Manjaro Linux to represent the Arch Linux distribution.

Method 1: Install NVM by Pacman Command


In this method, we will use the default package manager (Pacman) command to install the NodeJS and NPM tools on our Arch Linux. You can then run the following Pacman command and the NVM command given below to install the NVM tool on your Arch Linux system.

sudo pacman -S nodejs npm
nvm install node

If you are not comfortable with the Pacman command method, you can also download the compressed version of the NVM package for Arch Linux from here. Then you have to install the package manually on your system. Here, you can find the detailed pieces of information for NVM for Arch Linux.

Download Node version manager on Arch

Method 2: Install NVM from Software Store


Linux developers have built a package of NVM for Arch Linux distribution. You can easily find the NVM package in the software store. You need to open the software store and search for NVM. You will find the list of NVM packages in the store.

Select your desired version of NVM from the package list and click on the install button. There you go, the NVM tool is now being installed inside your system. 

install NVM on Arch Linux from store

Configure Node Version Manager on Linux


Till now, we have seen how you can install the NVM tool on various Linux distributions. Now, we will see how you can configure and get started with the NVM tool. You can pick the most suitable version of the NVM tool available for your Linux system. Run the following command-lines given below to see the version of the NVM tool.

nvm --version
node -v
npm -v
nvm ls

NVM on Fedora Linux LS

Now, run the following command to see the available list of the NVM tool for your system.

nvm ls-remote

list of available Node managers

Run the following nvm use command to select a specific version of the NVM tool from the NVM package’s installed list on your Linux system.

nvm use 12.18.3

Run the following command to set a default version of the NVM tool.

nvm run default --version

Remove NVM from Your Linux System


First, to remove the NVM package from the Linux system, you must remove the NPM tool from your system. Run the following command-lines given below to remove the NPM tool from your system. You can then remove the NVM tool from your Linux system.

  • Remove Node Version Manager from Ubuntu/Debian Linux.
sudo apt remove nodejs npm
npm uninstall package-name
nvm uninstall <version>
  • Remove NodeJS and NPM from your Fedora Linux.
sudo yum remove nodejs
dnf remove npm

Clear and remove the system files of NodeJS from your system.

sudo rm -rf /var/cache/yum
sudo yum remove -y nodejs
sudo rm /etc/yum.repos.d/nodesource*
sudo yum clean all

If you are using the Manjaro and other Arch Linux system, you will find the removal option of packages in the Software store inside the installed package section.

Final Words


As we have already seen, the node version manager works with the NodeJS repository, so it is important to ensure that the NodeJS is installed inside your Linux system. You can find the backup files automatically generated by the NVM inside the /.profile directory on your Linux system. In this post, I have described how you can install and get started with the NVM tool on various Linux distributions.

If you find this post useful and handy, please share it with your friends and the Linux community. You can also write your opinions regarding this post in the comment section.

Mehedi Hasan
Mehedi Hasan
Mehedi Hasan is a passionate enthusiast for technology. He admires all things tech and loves to help others understand the fundamentals of Linux, servers, networking, and computer security in an understandable way without overwhelming beginners. His articles are carefully crafted with this goal in mind - making complex topics more accessible.

LEAVE A REPLY

Please enter your comment!
Please enter your name here


You May Like It!

Trending Now