• Home
  • Ubuntu 20.04
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us
TecAdmin
Menu
  • Home
  • Ubuntu 20.04
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us

How to Install and Manage Node.js via NVM

Written by Rahul, Updated on July 14, 2020

NVM is known as Node Version Manager, Similarily to RVM (Ruby Version Manager) for Ruby language. NVM provides an option for the easy installation of Node.js. You can also install a specific Node.js version or multiple Node.js versions on the same system using nvm and use the required version for the application. This tutorial will help you to Install and Manage Node.js using NVM.

The default NVM installs under current users home directory, So nvm installation with one user will not be accessible to another user. Windows users can visit our other tutorial to install Nodejs on Windows system.

Step 1 – Install NVM

First of all, you need to install NVM on your system. A Bash script is available to install nvm on your system. Use the following command to install NVM on your Linux system.

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

Reload system environment using this command. It will set the required environment variables to use nvm on the system.

source ~/.profile     ## Debian based systems 
source ~/.bashrc      ## CentOS/RHEL systems 

Step 2 – Find Available Node.js Version

At this point, you have installed nvm on your system for the current user. Now find out the available version of Node.js to install. Use ls-remote option to list versions.

nvm ls-remote

You will see a long list of available versions.

       ...
       ...
       v12.16.2   (LTS: Erbium)
       v12.16.3   (LTS: Erbium)
       v12.17.0   (LTS: Erbium)
       v12.18.0   (LTS: Erbium)
       v12.18.1   (LTS: Erbium)
       v12.18.2   (Latest LTS: Erbium)
       ...
       ...
        v14.2.0
        v14.3.0
        v14.4.0
        v14.5.0

Step 3 – Installing Node.js with NVM

Now install the node.js version you need to use for running node.js application. Below command will install node.js 12.16.2 the LTS release on your system.

nvm install v12.18.2

You can have also installed the latest version of Node.js.

nvm install v14.5.0

Repeat the above command with the different-2 node.js versions to install multiple versions of node.js on your system.

Step 4 – Set Node.js Default Version

As you have installed multiple node.js versions, You can select the specific version of node.js as default version used by system and load in the environment. Use below command to list currently installed version and default set version.

nvm list

->     v12.18.2
        v14.5.0
         system
default -> 12 (-> v12.18.2)
node -> stable (-> v14.5.0) (default)
stable -> 14.5 (-> v14.5.0) (default)
iojs -> N/A (default)
unstable -> N/A (default)
lts/* -> lts/erbium (-> v12.18.2)
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.2

You can see that Node.js version v12.18.2 is set as the default version. You can change the default Node.js version. The below command will set 12.18.2 as default Node.js version.

nvm use v12.18.2

Now verify current active version of node.js

node --version

v12.18.2

Step 5 – Run Application with Specific Version

If you have multiple node.js applications on your system and want to run each with a specific version of node.js. NVM provides you an option to use a node.js version for running any application. For example

nvm run v12.18.2 app.js

Step 6 – Remove Unused Node.js Version

This command will provide a list of installed versions of node.js on your system.

nvm list

You can remove any unused version from your system. Use the following nvm command to remove Node.js version 4.9.1 from your system.

nvm uninstall v4.9.1

Share it!
Share on Facebook
Share on Twitter
Share on LinkedIn
Share on Reddit
Share on Tumblr
Share on Whatsapp
Rahul
Rahul
Connect on Facebook Connect on Twitter

I, Rahul Kumar am the founder and chief editor of TecAdmin.net. I am a Red Hat Certified Engineer (RHCE) and working as an IT professional since 2009..

20 Comments

  1. Avatar Hamza Ilyas Reply
    December 20, 2020 at 9:04 pm

    Thanks Bro!

  2. Avatar bhargav Reply
    December 11, 2020 at 6:10 am

    No Non-Sense Explanation, Very useful.
    Thankyou.

  3. Avatar Anatolii Reply
    June 17, 2020 at 11:56 am

    This works great!

  4. Avatar tunnel Reply
    May 31, 2020 at 10:33 am

    perfect.

  5. Avatar Muzamil Reply
    May 12, 2020 at 1:31 pm

    Nice very informative and updated,,,million thanks

  6. Avatar JeanCarlos Reply
    May 3, 2020 at 6:39 pm

    Thanks, the guide is very concise and useful.

  7. Avatar Jax Reply
    October 14, 2019 at 1:21 pm

    Thx!

  8. Avatar HASEEB UR REHMAN Reply
    August 28, 2019 at 10:52 am

    thanks

  9. Avatar Oscar Aksanti Reply
    July 30, 2019 at 7:56 am

    Wow, it works,
    ça marche correctement. Merci

  10. Avatar J.C. Reply
    July 10, 2019 at 10:50 pm

    Many thanks 😀

  11. Avatar Diego Reply
    July 2, 2019 at 8:47 pm

    thanks alot man!

  12. Avatar Allan V. Pimble, Sr. Reply
    June 27, 2019 at 3:25 pm

    Thank you very much. This just what I needed to install the latest version of Nodejs on MX Linux. Other methods responded with an error message stating that it could not be installed on ‘Continuum’.

    System Info: ‘Desktop: Xfce 4.12.3 Distro: MX-18.3_x64 Continuum Feb 9 2019’

  13. Avatar npmVnpm Reply
    June 6, 2019 at 8:24 am

    i found out that nvm is easier to use compared to npm. thanks!

  14. Avatar R Reply
    June 4, 2019 at 9:39 am

    `nvm remove v10.15.0` is not a valid command. Use `nvm uninstall v10.15.0`

    • Rahul Rahul Reply
      June 4, 2019 at 10:15 am

      Thanks R,

  15. Avatar tdminh Reply
    January 4, 2019 at 10:59 am

    Thank you

  16. Avatar raja Reply
    June 6, 2018 at 4:20 am

    Thanks for ur information

  17. Avatar Srikar Reply
    May 22, 2018 at 2:05 pm

    Thanks for detailing them!

  18. Avatar Burak Reply
    April 20, 2018 at 2:16 pm

    Life saver, thanks

  19. Avatar J.K. Reply
    May 8, 2016 at 4:22 am

    Thanks for your help…

Leave a Reply Cancel reply

Popular Posts

  • How To Install Python 3.9 on Debian 10
  • Download Ubuntu 20.04 LTS – DVD ISO Images
  • Linux Run Commands As Another User
  • How to Check PHP Version (Apache/Nginx/CLI)
  • How To Install and Configure GitLab on Ubuntu 20.04
  • How to Install PyCharm on Ubuntu 20.04
  • How to Check Ubuntu Version with Command or Script
  • How to Set all directories to 755 And all files to 644
© 2013-2021 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy