Facebook X (Twitter) Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook X (Twitter) Instagram
    TecAdmin
    You are at:Home»Node.js and Web Development Tools»How To Install NVM on Ubuntu 22.04

    How To Install NVM on Ubuntu 22.04

    By RahulApril 15, 20233 Mins Read

    Node Version Manager (NVM) is a popular tool that allows you to manage multiple Node.js versions on your system. With NVM, you can easily switch between different Node.js versions, install new ones, and remove the ones you no longer need.

    This article will guide you through the process of installing NVM on Ubuntu 22.04 and getting started with using it to manage your Node.js installations. Also, provide you with the instructions to install multiple Node.js versions with useful examples.

    Prerequisites

    • You must have a running Ubuntu 22.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 22.04 (Jammy Jellyfish) 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 ~/.profile 
    

    Installing Node using NVM

    You can install any number of node.js versions of your requirements using nvm. Then you can 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 16.14.0  
      

    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 
    

    List available node.js versions 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 16.14.0 
    

    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 16.14.0 server.js 
    

    Conclusion

    In this article, you have learned how to install NVM on Ubuntu 22.04 and use it to manage multiple Node.js versions. NVM is a powerful tool for developers who need to work with different Node.js versions for various projects. With NVM, you can easily switch between Node.js versions, install new ones, and remove the ones you no longer need. This ensures that your development environment remains clean and organized, allowing you to focus on writing and testing code. Enjoy the flexibility and ease of managing Node.js versions with NVM on your Ubuntu 22.04 system!

    NodeJs nvm Ubuntu 22.04
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    How to Install Google Chrome on Ubuntu 22.04

    Setting Up Angular on Ubuntu: Step-by-Step Guide

    Create a Basic CRUD API in NodeJS, ExpressJS and MySQL

    View 1 Comment

    1 Comment

    1. Renzo on July 9, 2023 4:10 pm

      HI. I don’t know why but I keep getting
      Command ‘nvm’ not found

      I’ve followed the procedure according to the tutorial. I’m using Ubuntu 22 LTS, only difference was that I installed curl through snapp install .

      My .bashrc file does have the exported lines

      export NVM_DIR=”$HOME/.nvm”
      [ -s “$NVM_DIR/nvm.sh” ] && \. “$NVM_DIR/nvm.sh” # This loads nvm
      [ -s “$NVM_DIR/bash_completion” ] && \. “$NVM_DIR/bash_completion” # This loads nvm bash_completion

      Reply

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • Difference Between Full Virtualization vs Paravirtualization
    • Virtualization vs. Containerization: A Comparative Analysis
    • Using .env Files in Django
    • Using .env File in FastAPI
    • Setting Up Email Notifications for Django Error Reporting
    Facebook X (Twitter) Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

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