How To Install NVM on Ubuntu 24.04

If you’re a web developer designing runtime web applications or websites, you must have heard of or used Node.js. If you are using Ubuntu or any other Linux distribution, you must install the NVM on your Linux distribution. NVM helps in managing Node.js on your Ubuntu or Linux system. This is because some projects require specific Node.js versions. This is where the NVM (Node Version Manager) comes in.

This guide covers NVM installation for Ubuntu 24.04.

Table of Contents:

What is NVM (Node Version Manager)?

NVM, also known as Node Version Manager, is a helpful tool that lets you switch across different Node.js versions on your system. This makes it easier for programmers and developers to work on projects requiring a specific version. 

NVM is beneficial because Node.js versions change rapidly, and testing applications with different versions can be challenging. With NVM, you can change the current Node version to any older or near with NVM.

Here are some of the main highlights of NVM:

  • Version Switching: Easily switch between different Node.js versions.
  • User Directory Storage: NVM stores the Node version and associated modules inside the user directory, eliminating the need for sudo.
  • Simplified Installation: No need to obtain Node versions directly from distribution channels.

Now that we have discussed NVM’s advantages, let’s proceed with its installation in the Ubuntu 24.04 system.

How to Install NVM on Ubuntu 24.04

To install NVM in Ubuntu 24.04, you can directly download the NVM script with the curl or wget command. Once the installation script is downloaded, you can run it using the nvm command.

Before you download the NVM script, first update your system packages:

sudo apt update

To get the NVM installation script, we are going to use the curl command. If it is not available on your system, you can get it using this command:

sudo apt install curl

Now, simply connect to remove the SSH server using curl and download the NVM script with this command:

curl | bash

After installation, source the new instructions added to your .bashrc file:

source ~/.bashrc

Once NVM is installed, exit or refresh the terminal using the newgrp command.

To confirm its installation, you can check the NVM version using this command:

nvm --version

Basic NVM Commands

There are different NVM commands for installing, removing, or checking the Node.js version on your Ubuntu machine. Now, we will cover some of these main commands.

To list all the available Node.js versions that can be installed using NVM, run this command:

nvm list-remote

To install the latest stable version of Node.js, you can use this command:

nvm install node

If you want to install the LTS version of Node.js, you can run this command:

nvm install --lts

Similarly, if you want to get any specific version of Node.js then run this command and specify the version number that you need to install on the Ubuntu 24.04 system:

nvm install 11.5

To get a stable version of Node.js, then run this command:

nvm install stable

To run the Node script with your desired version of Node.js, run this command:

nvm exec 18.16.0 server.js

How to Install Different Node.js Versions Using NVM

The main principle behind using the NVM over the conventional method of Node.js installation is because of its flexibility to install and switch to other Node.js versions right through the terminal. Now we will cover some basic commands that help you install different Node.js versions and how you can switch between them.

To check the default Node.js version, run the default –version command. It executes the default Node.js script (usually index.js) and displays its version:

nvm run default --version

To list all locally installed Node.js versions, run the below command. This will also indicate the currently active version:

nvm ls

If you have installed multiple versions of Node.js and want to change the current version to any other version, then you can use the nvm use command like this:

nvm use 18.16.0

You can also use the NVM command to remove any particular version of Node.js from your system:

nvm uninstall 18.16.0

Note: Before uninstalling any Node.js version, ensure that you shift to another version; otherwise, the current set version can not be uninstalled unless stopped or changed.

These are all the basic NVM commands that you can explore on your Ubuntu 24.04 system.

How to Uninstall NVM on Ubuntu

To uninstall NVM from Ubuntu, you have to remove the NVM directory. This directory is located at ~/.nvm. To remove this directory, run this command:

rm -rf ~/.nvm

This will completely delete the NVM files and folders.


Node Version Manager (NVM) helps you manage multiple Node.js versions directly from the terminal. It simplifies switching between different Node.js versions for web server application testing. To install NVM on Ubuntu you can simply download the NVM installation script using the curl or wget command. After that, NVM can be started by using the nvm command directly from the terminal.