Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

Install nvm (Node Version Manager) on Ubuntu

Install nvm, then install and switch Node.js versions without sudo.

How-To Guides2 min read8 screenshots
nvm on Ubuntu

What nvm is

nvm (Node Version Manager) installs and manages many Node.js versions for one user. You can switch between them in a second. That is helpful when projects need different versions.

Step 1: Update the system

sudo apt update && sudo apt upgrade -y
Updating the system

Step 2: Install curl

sudo apt install curl -y
Installing curl

Step 3: Download and install nvm

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

Check the nvm project page for the newest version number. Then load it into your shell:

source ~/.bashrc

Step 4: Check nvm

nvm --version
The nvm version

The answer is a version number such as 0.40.3.

Step 5: Install Node.js

The latest version:

nvm install node
Installing the latest Node.js
node -v
The Node.js version

The latest LTS (long-term support) version:

nvm install --lts
Installing the LTS version

Common nvm commands

CommandWhat it does
nvm lsLists the installed versions
nvm ls-remoteLists the versions you can install
nvm use <version>Switches to a version
nvm uninstall <version>Removes a version
nvm alias default 18.17.1Sets the default version for new shells
nvm currentShows the active version

Uninstall nvm

Remove the folder and the lines it added to your shell file:

rm -rf ~/.nvm

Then delete the three nvm lines from ~/.bashrc (and ~/.profile if present), and open a new terminal.

Quick recap

  • Install with the script, then source ~/.bashrc.
  • nvm install --lts installs Node.js.
  • nvm use <version> switches.