Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Programming»Nodejs»How To Install NVM on Ubuntu 20.04

    How To Install NVM on Ubuntu 20.04

    By RahulJuly 12, 20223 Mins Read

    NVM is a Node Version Manager tool. Using the NVM utility, you can install multiple node.js versions on a single system. You can also choose a specific Node version for applications. It also provides an option to auto-select the node version using the .nvmrc configuration file.

    Advertisement

    This tutorial will help you to install NVM on Ubuntu 20.04 Linux system. Also, allow you to install different node versions and other useful examples.

    Prerequisites

    • You must have a running Ubuntu 20.04 Linux system with shell access.
    • Log in with a user account to which you need to install node.js.

    Installing NVM on Ubuntu

    A shell script is available for the installation of nvm on the Ubuntu 20.04 Linux system. Open a terminal on your system or connect a remote system using SSH. Use the following commands to install curl on your system, then run the nvm installer script.

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

    The nvm installer script creates an environment entry to the login script of the current user. You can either log out and log in again to load the environment or execute the below command to do the same.

    source ~/.bashrc   
    

    The nvm installation is successfully completed on your Ubuntu system.

    Installing Node using NVM

    You can install multiple node.js versions using nvm. And use the required version for your application from installed node.js.

    Install the latest version of node.js. Here node is the alias for the latest version.

    nvm install node 
    

    To install a specific version of node:

    nvm install 12.18.3  
    

    You can choose any other version to install using the above command. The very first version installed becomes the default. New shells will start with the default version of the node (e.g., nvm alias default).

    Working with NVM

    You can use the following command to list installed versions of the node for the current user.

    nvm ls 
    

    With this command, you can find the available node.js version for the installation.

    nvm ls-remote 
    

    You can also select a different version for the current session. The selected version will be the currently active version for the current shell only.

    nvm use 12.18.3 
    

    To find the default Node version set for the current user, type:

    nvm run default --version 
    

    You can run a Node script with the desired version of node.js using the below command:

    nvm exec 12.18.3 server.js 
    

    Conclusion

    In this tutorial, you have learned to install nvm on Ubuntu 20.04 LTS (Focal Fossa) Linux system. Also, get a basic understanding of the uses of nvm.

    node NodeJs nvm
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    How to Create React.js Application on macOS

    How to list all collections in MongoDB database

    How to Install Grunt on Ubuntu 22.04 & 20.04

    View 9 Comments

    9 Comments

    1. jagannathadasa on February 5, 2023 12:34 am

      It really worked for me. Awesome

      Reply
    2. Alexei Semenov on December 27, 2021 8:39 am

      Simplest way I have seen so far
      Thanks

      Reply
    3. Mikec711 on November 26, 2021 1:32 pm

      Thanks for this. My repositories were so trashed, I had to start from scratch. This was very helpful.

      Reply
    4. Menja on October 24, 2021 2:30 pm

      To set any version into Default use this.
      nvm alias default [version_here]

      Reply
    5. pharis on July 23, 2021 8:24 am

      On point. Really helpful

      Reply
    6. Kibet on May 9, 2021 8:43 am

      This article saved me brother. Thank you!

      Reply
    7. Diwas Adhikari on April 22, 2021 10:12 am

      nice own bro. it helped alot

      Reply
    8. Adam on February 14, 2021 7:31 am

      Awesome

      Reply
    9. Vinoth on January 3, 2021 3:31 pm

      Sir you did awesome blog with answers, as am developer I really appreaciate for your work. Thank you for such a brief block with correct details. I wish you that you continue like this..

      Reply

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • Implementing a Linux Server Security Audit: Best Practices and Tools
    • cp Command in Linux (Copy Files Like a Pro)
    • 15 Practical Examples of dd Command in Linux
    • dd Command in Linux (Syntax, Options and Use Cases)
    • Iptables: Common Firewall Rules and Commands
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

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