Introduction

NVM (Node Version Manager) is a tool used to manage multiple versions of Node.js on a single system. Installing and using NVM on Ubuntu 22.04 allows you to easily switch between different Node.js versions for your projects. In this guide, we'll walk you through the step-by-step process of installing and using NVM on Ubuntu 22.04.

Prerequisites

Before you begin, make sure you have the following:

  • An Ubuntu 22.04 system with sudo privileges
  • A stable internet connection

Step 1: Install NVM

Open a terminal on your Ubuntu 22.04 system and run the following command to download and install NVM:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash

After the installation is complete, you may need to restart your terminal or run the following command to start using NVM:

source ~/.bashrc

Step 2: Verify NVM Installation

To verify that NVM has been installed correctly, run the following command:

nvm --version

This command should display the installed version of NVM.

Step 3: Install Node.js with NVM

Once NVM is installed, you can use it to install Node.js. For example, to install the latest LTS version of Node.js, run the following command:

nvm install --lts

To install a specific version of Node.js, replace --lts with the version number. For example:

nvm install 14.17.6

Step 4: Use Node.js Versions with NVM

After installing Node.js versions with NVM, you can use them by running the following command and specifying the version:

nvm use node_version

Replace node_version with the version of Node.js you want to use.

Step 5: Set Default Node.js Version with NVM

To set a default Node.js version to be used by NVM, run the following command:

nvm alias default node_version

Replace node_version with the version of Node.js you want to set as default.

Conclusion

Congratulations! You've successfully installed and used NVM (Node Version Manager) on Ubuntu 22.04. You can now manage multiple versions of Node.js on your system with ease.

Thank you for reading our guide on how to install and use NVM (Node Version Manager) on Ubuntu 22.04. We hope you found it helpful!

Was this answer helpful? 0 Users Found This Useful (0 Votes)