Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Programming»Nodejs»How to Install and Manage Node.js via NVM

    How to Install and Manage Node.js via NVM

    By RahulMay 1, 20164 Mins ReadUpdated:December 15, 2022

    NVM is known as Node Version Manager, similarly 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.

    Advertisement

    The default NVM is installed under the current user’s 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

    NVM is a command-line utility to install and manage Node.js versions for specific users. You can install nvm using a shell script provided by the nvm team.

    1. First, make sure you have curl installed on your system:
      sudo apt update && sudo apt install curl -y
      
    2. Next, run the following command to configure nvm on your system for the current logged user.
      curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash 
      
    3. Reload the system environment using this command. It will set the required environment variables to use nvm on the system.
      • Debian based systems:
        source ~/.profile 
        
      • CentOS, Fedora and Redhat systems:
        source ~/.bashrc  
        

    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.

    Output:
    ... ... v16.12.0 v16.13.0 (LTS: Gallium) v16.13.1 (LTS: Gallium) v16.13.2 (LTS: Gallium) v16.14.0 (Latest LTS: Gallium) v17.0.0 v17.0.1 v17.1.0 v17.2.0 v17.3.0 v17.3.1 v17.4.0 v17.5.0

    Step 3 – Installing Node.js with NVM

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

    nvm install v16.14.0 
    

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

    nvm install 17 
    

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

    Step 4 – Set A Default Version

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

    nvm list 
    
    Output:
    v16.13.2 -> v16.14.0 v17.5.0 system default -> 16 (-> v16.14.0) iojs -> N/A (default) unstable -> N/A (default) node -> stable (-> v17.5.0) (default) stable -> 17.5 (-> v17.5.0) (default) lts/* -> lts/gallium (-> v16.14.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.24.1 (-> N/A) lts/erbium -> v12.22.10 (-> N/A) lts/fermium -> v14.19.0 (-> N/A) lts/gallium -> v16.14.0

    You can see that Node.js version v16.14.0 is set as the default version. You can change the default Node.js version. The below command will set 17.5.0 as the default Node.js version.

    nvm use 17.5.0 
    

    Now verify the current active version of node.js

    node --version 
    
    v17.5.0
    

    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 v16.14.0 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. For example, to remove Node.js version 9.5.9 execute the following command:

    nvm uninstall v9.5.0 
    

    Conclusion

    This tutorial helped you to install and configure multiple Node.js versions using NVM. This guide also describes you to switch from the default version with the nvm utility and instructions to use different versions during the run time.

    node.js nodejs with nvm npm nvm
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    Error: EACCES: permission denied, scandir (Resolved)

    How to Install Grunt on Ubuntu 22.04 & 20.04

    Running “npm start” with PM2

    View 23 Comments

    23 Comments

    1. Richard on May 16, 2022 8:41 pm

      Muchas gracias, excelente documento. Claro, preciso y conciso. Saludos desde Perú.

      Reply
    2. Hendalee Wilson on April 1, 2021 1:26 pm

      Clear and concise. Thank you for the gift of time saved!

      Reply
    3. Raja Nagendra on March 25, 2021 6:21 am

      Works great.. thank you.

      Reply
    4. Hamza Ilyas on December 20, 2020 9:04 pm

      Thanks Bro!

      Reply
    5. bhargav on December 11, 2020 6:10 am

      No Non-Sense Explanation, Very useful.
      Thankyou.

      Reply
    6. Anatolii on June 17, 2020 11:56 am

      This works great!

      Reply
    7. tunnel on May 31, 2020 10:33 am

      perfect.

      Reply
    8. Muzamil on May 12, 2020 1:31 pm

      Nice very informative and updated,,,million thanks

      Reply
    9. JeanCarlos on May 3, 2020 6:39 pm

      Thanks, the guide is very concise and useful.

      Reply
    10. Jax on October 14, 2019 1:21 pm

      Thx!

      Reply
    11. HASEEB UR REHMAN on August 28, 2019 10:52 am

      thanks

      Reply
    12. Oscar Aksanti on July 30, 2019 7:56 am

      Wow, it works,
      ça marche correctement. Merci

      Reply
    13. J.C. on July 10, 2019 10:50 pm

      Many thanks 😀

      Reply
    14. Diego on July 2, 2019 8:47 pm

      thanks alot man!

      Reply
    15. Allan V. Pimble, Sr. on June 27, 2019 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’

      Reply
    16. npmVnpm on June 6, 2019 8:24 am

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

      Reply
    17. R on June 4, 2019 9:39 am

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

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

        Thanks R,

        Reply
    18. tdminh on January 4, 2019 10:59 am

      Thank you

      Reply
    19. raja on June 6, 2018 4:20 am

      Thanks for ur information

      Reply
    20. Srikar on May 22, 2018 2:05 pm

      Thanks for detailing them!

      Reply
    21. Burak on April 20, 2018 2:16 pm

      Life saver, thanks

      Reply
    22. J.K. on May 8, 2016 4:22 am

      Thanks for your help…

      Reply

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • Error: EACCES: permission denied, scandir (Resolved)
    • How To Install Python 3.11 on Ubuntu 22.04 / 20.04
    • How to Install Python 3.11 on Amazon Linux 2
    • An Introduction to the “./configure” Command: Compiling Source Code in Linux
    • How to Install PHP 8.x on Pop!_OS
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.