Install Node.js Locally with NVM.(Node Version Manager)

Hi Techies! Today we will see about “Install Node.js Locally with NVM (Node Version Manager) on Ubuntu”. NVM is a Node Version Manager.

Using Node Version Manger we can have multiple versions of Node.js on a single system with that particular user.

So NVM can be installed by many users on the same system, without having any issue or the versions conflicts. We can use latest version, then if want we can switch back to the older version, and we can use the stable version for the Node.js.

So in this article, will see the following steps to install Node.js Locally with NVM.

  • How to download and Install the NVM (Node Version Manger) Script.
  • List the Node versions using NVM (Node Version Manger).
  • Install the Node.js with NVM (Node Version Manger) locally.
  • Install the different version of Node.js with NVM (Node Version Manger).
  • How to Switch the versions of Node.js using NVM (Node Version Manger).

How to download and Install the NVM (Node Version Manger) Script.

So let’s download the script for NVM locally by using curl command, and if you have to install the curl command in linux system use the below command.

In Ubuntu/Debian/Linux Mint.

$ sudo apt install curl

In Red Hat/CentOS/Rocky Linux.

$ sudo dnf install curl

So now we will download the script for NVM (Node Version Manager) locally.

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
Install Node.js on Ubuntu
Install nvm on local System
$ source ~/.bashrc

Once we reload the “.bashrc” file, then we have install NVM (Node Version Manager) locally.


List the Node versions using NVM (Node Version Manger)

So after installation of Node.js we will use NVM command to check the version that are available remotely.

 $ nvm list-remote

OUTPUT:
       v14.17.5   (LTS: Fermium)
       v14.17.6   (Latest LTS: Fermium)
        v15.0.0
        v15.0.1
        v15.1.0
        v15.2.0
        v15.2.1
        v15.3.0
        v15.4.0
        v15.5.0
        v15.5.1
        v15.6.0
        v15.7.0
        v15.8.0
        v15.9.0
       v15.10.0
       v15.11.0
       v15.12.0
       v15.13.0
       v15.14.0
        v16.0.0
        v16.1.0
        v16.2.0
        v16.3.0
        v16.4.0
        v16.4.1
        v16.4.2
        v16.5.0
        v16.6.0
        v16.6.1
        v16.6.2
        v16.7.0
        v16.8.0

So we have list the versions, it upon to us now which version is best suits to your project, our you want to install the stable version.


Install the Node.js with NVM (Node Version Manger) locally.

Suppose we have to install the Stable LTS version of Node.js 14.17.6 using NVM (Node Version Manger) locally.

nvm install v14.17.6
$ nvm install v14.17.6

So once the installation has been done we will list the NVM to check the installed version for Node.js.

$ nvm list

Also we can check the versions with node and npm command on the command line.

$ node -v
$ npm -v

Install the different version of Node.js with NVM

So now lets install 16.6.2 version of Node.js using NVM(Node Version Manager) locally.

nvm install v16.6.2
$ nvm install v16.6.2

So we have installed 16 versions of node js with 7.20 of an NPM. lets check the version for a Node.js

Install Node.js on Ubuntu nvm list
nvm list
$ nvm list

So we can see both the version now, but the active is Node.js version 16. Same we can check with the node and npm command.

$ node -v
$ npm -v

How to Switch the versions of Node.js using NVM (Node Version Manger).

Now let’s downgrade the version, or we can Update the version for Node.js.

Install Node.js on Ubuntu nvm use to switch
nvm use v14.17.6
$ nvm use v14.17.6

We have switched the version for Node.js successfully from 16 to 14 locally using NVM, let’s check the active version on system.

Also, we can check the versions with the node and npm command.

$ node -v
$ npm -v

So with the help of NVM(Node Version Manger) it very simple to install any version of Node.js locally, Also it’s very easy to switch the version between the same.


One Reply to “Install Node.js Locally with NVM.(Node Version Manager)”

Give your valuable time