Ubuntu Linux

How to Install NVM on Ubuntu: A Step-by-Step Guide

Richard
Written by
Richard
Oct 20, 2022 Updated Mar 19, 2026 4 min read
How to Install NVM on Ubuntu: A Step-by-Step Guide

This article describes installing and using nvm (node version manager) on Ubuntu Linux.

Nvm is a version manager for node.js, designed to be installed per user and invoked per shell. It can install and manage node.js packages on Linux, macOS, and Windows with WSL.

If you are a developer and want to install and manage multiple versions of node.js on the same system and use a specific version for a specific project, you can use nvm.

Nvm also lets you quickly install and use different versions of nodes via the command line.

Below is how to install nvm on Ubuntu Linux.

How to install nvm on Ubuntu Linux

As mentioned above, nvm allows you to quickly install and use different versions of nodes via the command line.

The steps below show you how to do that on Ubuntu Linux.

Install nvm

To install or update nvm, you should run the install script. To do that, you may either download and run the script manually or use the following cURL or Wget command.

cURL command:

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

Wget command:

💻Code
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash

Either of the commands above should download the nvm install script that can be used to install. The script clones the nvm repository to ~/.nvm, and attempts to add the source lines from the snippet below to the correct profile file (~/.bash_profile~/.zshrc~/.profile, or ~/.bashrc).

After installing, the script should output the lines below.

💻Code
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

Once downloaded, you can then activate and reload your shell environment. By default, it’s bash (~/.bashrc).

💻Code
source ~/.bashrc

To check the version of nvm installed, run the commands below.

💻Code
nvm --version

Install Node.js with nvm

As mentioned above, nvm can be used to install and manage node.js.

Run the commands below to download and install the current and latest version of node.js.

💻Code
nvm install node

Once installed, you can check the version of node.js installed by running the commands below.

💻Code
node --version

Run the commands below to install the latest stable version (long-term support).

💻Code
nvm install node --lts

To install a specific version (12.17.0), run the commands below.

💻Code
nvm install 12.17.0

To list all available versions in the repository, run the commands below.

💻Code
nvm ls-remote

If you have multiple versions of node.js installed, run the commands below to specify the version you want to use.

💻Code
nvm use 12.17.0

To find the current default node.js installed, run the commands below.

💻Code
nvm run default --version

Uninstall node.js

To uninstall node.js, run the commands below.

💻Code
nvm uninstall v12.17.0

That should do it!

Conclusion:

  • Nvm is a valuable tool for developers to manage multiple versions of node.js on their systems easily.
  • By following the installation instructions, developers can quickly install and use different versions of node.js via the command line.
  • The provided guide simplifies installing nvm on Ubuntu Linux and showcases how to install and manage node.js using nvm.
  • Users are encouraged to provide feedback or suggestions for improvement through the comment section below.

Frequently Asked Questions

What is NVM and why should I use it?

NVM, or Node Version Manager, is a tool that allows developers to install and manage multiple versions of Node.js on their system. It is particularly useful for working on different projects that may require different Node.js versions.

How do I install NVM on Ubuntu?

To install NVM on Ubuntu, you can use either the cURL or Wget command to download the installation script. Simply run 'curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash' or 'wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash' in your terminal.

How can I check the version of NVM installed?

You can check the installed version of NVM by running the command 'nvm --version' in your terminal. This will display the current version of NVM that is active on your system.

What command do I use to install a specific version of Node.js with NVM?

To install a specific version of Node.js using NVM, you can run the command 'nvm install ', replacing '' with the desired version number, such as 'nvm install 12.17.0'.

How do I uninstall Node.js using NVM?

To uninstall a specific version of Node.js with NVM, use the command 'nvm uninstall ', replacing '' with the version you want to remove, such as 'nvm uninstall v12.17.0'. This will remove that version from your system.

Was this guide helpful?

Richard

About the Author

Richard

Tech Writer, IT Professional

Richard, the owner and lead writer at Geek Rewind, is a tech enthusiast passionate about simplifying complex IT topics. His years of hands-on experience in system administration and enterprise IT operations have honed his ability to provide practical insights and solutions. Richard aims to make technology more accessible and actionable. He's deeply committed to the Geek Rewind community, always ready to answer questions and engage in discussions.

2458 articles → Twitter

📚 Related Tutorials

Secure SSH Access on Ubuntu with Google Authenticator
Ubuntu Linux Secure SSH Access on Ubuntu with Google Authenticator
How to Setup GLPI with Nginx on Ubuntu Linux
CMS How to Setup GLPI with Nginx on Ubuntu Linux
How to Display Seconds on Ubuntu Top Menu Clock
Ubuntu Linux How to Display Seconds on Ubuntu Top Menu Clock
How to Completely Uninstall Docker from Ubuntu
Ubuntu Linux How to Completely Uninstall Docker from Ubuntu

Leave a Reply

Your email address will not be published. Required fields are marked *