How to Install NVM on Ubuntu 22.04
Last Updated :
11 Apr, 2025
Whether you are developing a web application, working with a Node.js-based project, or learning Node.js in general, NVM makes it easier to work with your Node.js environments in Ubuntu. In essence, NVM (Node Version Manager) is a useful tool for working with multiple versions of Node.js on your computer. Using NVM, you can easily install, switch between, and manage various Node.js versions for your development projects.
Prerequisites to Install NVM on Ubuntu
- Active Ubuntu 22.04
- apt package manager must be installed in your Ubuntu.
- curl command-line interface must be installed.
- Ensure that you have sudo or administrative privileges to execute the commands required.
Step 1: Update Package Repository
Before installing NVM, it's essential to ensure that your system's package repository is up-to-date. Open a terminal window by pressing Ctrl + Alt + T and execute the following command:
Before installing NVM, make sure that the package repository on your system is updated. In a terminal window, press Ctrl + Alt + T and then run the command:
sudo apt-get update
Updating package repository
Enter your password when prompted, and wait for the process to complete. This command updates the local package index to reflect the latest changes in the repository.
Step 2: Install Prerequisites
NVM comes with certain prerequisites that must be installed on your system prior to proceeding with the installation. To install the prerequisites, you can enter the following command in the terminal:
sudo apt install curl
installing curl in ubuntuThe above command installs the curl package, and it is utilized in downloading NVM and other resources.
Step 3: Download and Install NVM on Ubuntu
Once the prerequisites are installed, you may now download and install NVM. Run the following curl command in the terminal:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
installing nvm on ubuntuThe above command downloads the NVM installation script directly from the official GitHub repository and pipes it into the bash shell to run it. Make sure that you update v0.39.1 with the current version at the time of your installation.
After the installation script is complete, you may need to close and re-open your terminal window or run source ~/.bashrc to apply changes to your current shell session.
Step 4: Verify NVM Installation on Ubuntu
To ensure that NVM is installed correctly on your system, you can run the following command:
nvm --version
Verify nvm installationIf NVM has been installed properly, the above command will display the version of NVM installed.
Step 5: Install Node.js Using NVM
Individual versions of Node.js can be installed now using NVM installed. To install, for example, the latest LTS version of Node.js, run the following command:
nvm install --lts
nstalling node.js using nvm in UbuntuThe command will download and install the latest LTS version of Node.js.
Step 6: Switch Between Node.js Versions
One of the most significant things about NVM is that you can easily switch between versions of Node.js. To show you all the versions of Node.js installed on your system, you can use the following command:
nvm ls
listing node.js version in UbuntuThis command will display a list of installed Node.js versions, indicating which version is currently active.
To switch to a specific Node.js version, you can use the following command:
nvm use <version>
Replace <version> with the desired Node.js version, such as 14.17.0 or lts.
Conclusion
Installing the NVM on Ubuntu 22.04 is allows us to easily manage multiple versions of Node.js on the system which provides the flexibility and convenience for to your development projects. By following the steps outlined in this guide, you should be able to install NVM, verify the installation, install Node.js versions, and switch between them effortlessly. NVM simplifies the process of managing Node.js versions and ensures compatibility with your projects' requirements.
Similar Reads
How To Install 2048 on Ubuntu The 2048 game is a math-based puzzle game in which you must slide tiles on a 4x4 grid in one of four ways. Touching tiles of the same value are combined into tiles with the merged ones' extra value. After sliding, additional tiles appear at random, starting with a few 2-valued tiles. Before the boar
2 min read
How to Install Yarn on Ubuntu 20.04 Yarn is a fast, reliable, and secure package manager for Node.js applications. It offers improved dependency management compared to npm, the default package manager for Node.js. In this beginner-friendly guide, we'll walk you through the step-by-step process of installing Yarn on Ubuntu 20.04, ensur
4 min read
How to Install Podman on Ubuntu Podman is a container management tool that serves as an excellent alternative to Docker. It's designed to function without a central daemon, making it lightweight and easier to use. With Podman, you can manage containers just like you manage regular processes, which enhances security and simplifies
3 min read
How to Install Gvim on Ubuntu The text editor known as Vim, which stands for "Vi Improved," is a traditional one that is primarily used by programmers. It is commonly referred to as a "programmer's editor." It was created a long time ago, but it is still a well-liked editor that outperforms many rivals. It can be used for everyt
5 min read
How to Install Jellyfin Media Server on Ubuntu 22.04 Setting up Jellyfin Media Server on Ubuntu 22.04 LTS can seem daunting, especially for beginners. However, with the right steps, you can install and start using Jellyfin to organize and stream your media files in no time. Here, we will discuss the step-by-step process of installing Jellyfin Media Se
6 min read