Guide – Install and Manage Node.js using NVM on Linux [2020]

Node Version Manager (NVM) as the name says using NVM multiple node.js can be installed, managed, and used on single. Using NVM On Linux, a specific version of the node can be installed or multiple node.js can be installed. You can visit the NVM Github Readme page for more information.

The node can be installed directly using apt install node but it doesn’t install the latest version and to get the latest version, managing multiple versions of the node is difficult for a rookie like me. So its good to use NVM saves time and is easy to use On Linux.

3 Easy Steps To Install Node.js

  1. Install NVM.
  2. Install Node.js using NVM.
  3. Run Node.js

In short Installation of Nodejs on Linux:

  1. Install NVM by
    curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash
  2. Now install Nodejs by NVM using
    nvm install v12.18.0
  3. Success! Now Bookmark our blog 😛

Installing Node.js On Linux – Detailed Guide

#1. Install NVM on Linux

  1. Run NVM script to install NVM using below cURL
    curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash
  2. If you dont have cURL installed then use this command then run the NVM script sudo apt-get install curl
  3. Now exit your terminal and reopen it.
  4. Check NVM is installed and working using nvm --versionOutput:
    Geekyarea@chetan:~$ nvm --version
    0.35.3
    Geekyarea@chetan:~$

#2. Install Node.js using NVM

  1. Open nodejs.org and note down the version OR run nvm ls-remote to get all node versions.Output: (The Green colored version are stable and recommended by nodejs)
          v12.16.3   (LTS: Erbium)
           v12.17.0   (LTS: Erbium)
    ->     v12.18.0   (Latest LTS: Erbium)
            v13.0.0...
  2. Run nvm install v12.18.0 to install Node.js. You can install any version, here I am installing v12.18.0 as its suitable and most stable.Output:
    Downloading and installing node v12.18.0...
    Downloading https://nodejs.org/dist/v12.18.0/node-v12.18.0-linux-x64.tar.xz...
    ######################################################################## 100.0%
    Computing checksum with sha256sum
    Checksums matched!
    Now using node v12.18.0 (npm v6.14.4)
    Creating default alias: default -> v12.18.0

#3. Run Nodejs

Check node is installed and working by executing node --version

Output:

Geekyarea@Chetan:~$ node --version
v12.18.0
Geekyarea@Chetan:~$

PS: If this is the first time installing and learning node then you should stop here. If your trying other versions of the node then go ahead to managing multiple node.js using NVM.


Installing and Managing Multiple Node using NVM

I use the latest version of node and here you want to install or try a different version of node, I wanted to know why? Its none of my business but still its feels good to know and learn from you.

Once after installing NVM it becomes too easy to install and manage multiple Nodejs of different versions. All thanks to NVM.

#1. Installing Specific version of Node

As usual, just run the following command with the version of node you want without [](square bracket)
nvm install v[version here]

Example: nvm install v12.18.0

#2. Setting a Default Node

nvm alias default [version here] specifying a version will set that node as default.

If you want set stable version of the node then nvm alias default stable This will set the most stable available version of the node as default.

#3. Switch from one version Node to another version of Node

Even this is made so easy by NVM, just run the following command with our same old friend know as the version you wanted to use.
nvm use v[version here]

#4. Listing all the Installed Nodejs

nvm ls display all the installed versions of Nodejs on the system/server. Not only list but tells us the default, stable(installed), stable available too.

Geekyarea@chetan:~$ nvm ls
->     v12.18.0
         system
default -> v12.18.0
node -> stable (-> v12.18.0) (default)
stable -> 12.18 (-> v12.18.0) (default)
iojs -> N/A (default)
unstable -> N/A (default)
lts/* -> lts/erbium (-> v12.18.0)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.21.0 (-> N/A)
lts/erbium -> v12.18.0

#5. Run using a specific version of node

Running a specific version of the node can be done by nvm run [version_here] app.js

#6. Uninstalling/Removing Node.js

When I was trying node for the first time, I thought removing other versions of the node would be difficult as compared to installing and surprise. And the command to uninstall/remove node is
nvm uninstall [version_here]


Final Words On Installing and Managing Node.js using NVM on Linux

Oh well, I will more happy if you share your project link, or show me what you have built with Node.js and me as a beginner to Node I will be happy to learn something from you.

Beside few words are, the distro I used to install and write this guide is Ubuntu 20.04 and 18.04. You should not get any errors as far your using the same distro or on any Ubuntu-based distros like Pop OS.

And if you tried out this guide and worked (even with some workaround) on other distros, comment down for your fellow NodeMates XD. Bye Bye!

Get real time updates directly on you device, subscribe now.

Leave A Reply

Your email address will not be published.

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

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More