Install NVM – Complete Node Version Manager Guide

Install NVM Featured Image

To install NVM on Linux, macOS or WSL2, run the v0.41.0 install script from the nvm-sh repository, restart your terminal, then run nvm install --lts. Windows needs the separate nvm-windows installer instead. This guide covers both, plus the commands you need to switch Node.js versions.

Short version

Terminalbash
# Ubuntu, macOS, WSL2
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.41.0/install.sh | bash
# restart your terminal, then:
nvm install --lts
nvm use --lts
node -v

# Windows (PowerShell): install nvm-windows first, then:
nvm install lts
nvm use lts

Node Version Manager is the most convenient way to manage different Node.js versions. We, as developers, oftentimes need to change between different Node.js versions depending on the project. Without Node Version Manager, changing Node.js versions can be cumbersome. In this article, you will learn how to: install NVM on Ubuntu, install NVM on macOS, install NVM on WSL2 and install NVM on Windows.

Table of Contents

Important NVM Commands

The NVM commands are the same on every operating system except for Windows. Therefore, we are going to look at the most important NVM commands first to familiarize you with NVM. Note that nvm install also switches your current shell to the version it just installed.

The specific NVM Windows commands are listed in the Windows section.

Install Latest Node.js Version Using NVM

To install the latest version of Node.js, run:

Terminalbash
nvm install node

Install Node.js LTS Using NVM

To install the LTS version of Node.js, run:

Terminalbash
nvm install --lts

List Available Node.js Versions

To list all available Node.js versions that are supported in NVM, run:

Terminalbash
nvm ls-remote

Install Specific Node.js Version Using NVM

To install any other version of Node.js, run:

Terminalbash
nvm install {version}

Listing Installed Node.js Versions

To list all installed NVM versions, type:

Terminalbash
nvm list

Switching Node.js Versions Using NVM

To switch/enable a version of Node.js, run:

Terminalbash
nvm use {version}

Install NVM Windows

NVM does not directly support Windows. Therefore we need to use the nvm-windows package instead (listed in the NVM documentation as a Windows alternative). It is a separate project with more than 48,000 GitHub stars.

To install NVM on Windows, download the installer for your CPU, for example nvm-2.0.1-x64-setup.exe, from the nvm-windows releases page. After downloading, run the installer as a normal user, not as Administrator, and leave everything as default. If you already have the official Node.js installed, the installer asks whether to adopt it into NVM or remove it. Alternatively, run winget install nvm-windows in PowerShell.

The screenshots in this section come from an older nvm-windows release, so the installer and the output look different now.

install nvm on windows

Using NVM on Windows

To use NVM on Windows, we need to use PowerShell.

  1. Press the Windows Key and search for PowerShell.
  2. Launch PowerShell.
  3. Run the nvm command to verify that NVM is installed.
Install NVM Windows

Install Latest Node.js Version on Windows

To install the latest Node.js version on Windows, run:

Terminalbash
nvm install latest

Followed by the command below to activate it:

Terminalbash
nvm use latest
install nvm windows

Install Node.js LTS on Windows

To install the LTS version of Node.js on Windows, run:

Terminalbash
nvm install lts

Followed by the command below to activate it:

Terminalbash
nvm use lts
install nvm windows

Install Specific Node.js Version on Windows

To install any other version of Node.js on Windows, run:

Terminalbash
nvm install {version}

To use that particular version:

Terminalbash
nvm use {version}

Install NVM Ubuntu

Installing NVM on Ubuntu is quick & easy. We can use either curl or wget to install NVM on Ubuntu. Make sure to install the latest version by checking it in the official GitHub repository.

Curl

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

Wget

Terminalbash
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.41.0/install.sh | bash

Running either of these commands will automatically update the respective ~/.bash_profile, ~/.zshrc, ~/.profile, or ~/.bashrc files.

Make sure to restart your terminal after the installation has finished or run the source ~/.{yourProfile} command to update your config.

Verify Installation

To verify if everything was installed correctly, run:

Terminalbash
nvm
install nvm ubuntu

Install Latest Node.js Version on Ubuntu

To install the latest Node.js version on Ubuntu, run:

Terminalbash
nvm install node
nvm use {version}
install nvm ubuntu

Install Node.js LTS on Ubuntu

To install the LTS version of Node.js on Ubuntu, run:

Terminalbash
nvm install --lts
nvm use {version}
install nvm ubuntu

Additional Commands

For more commands, check the important NVM commands section at the beginning of this article!

Install NVM WSL2

The steps to install NVM on WSL2 are the same as the steps for installing NVM on Ubuntu. Nevertheless, let’s quickly run through them. We can use either curl or wget to install NVM on WSL2. Make sure to install the latest version by checking it in the official GitHub repository.

Curl

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

Wget

Terminalbash
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.41.0/install.sh | bash

Running either of these commands will automatically update the respective ~/.bash_profile, ~/.zshrc, ~/.profile, or ~/.bashrc files.

Make sure to restart your WSL2 terminal after the installation has finished or run the source ~/.{yourProfile} command to update your config manually.

Verify Installation

To verify if everything was installed correctly, run:

Terminalbash
nvm
install nvm wsl2

Install Latest Node.js Version on WSL2

To install the latest Node.js version on WSL2, run:

Terminalbash
nvm install node
nvm use {version}
install nvm wsl2

Install Node.js LTS on WSL2

To install the LTS version of Node.js on WSL2, run:

Terminalbash
nvm install --lts
nvm use {version}
install nvm wsl2

Additional Commands

For more commands, check the important NVM commands section at the beginning of this article!

Install NVM macOS

There are two ways how to install NVM on macOS. You can either use Homebrew, or you install it by using either curl or wget.

Install NVM macOS Using Homebrew

If you do not have Homebrew installed, you can install it by using the following command:

Terminalbash
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

To install NVM on macOS with Homebrew, run:

Terminalbash
brew install nvm

The NVM project says Homebrew installs are not supported, so if you run into problems, use the curl or wget method below instead. The Homebrew formula also does not edit your shell profile for you. Create the NVM directory and add these lines to your ~/.zshrc (the path is /usr/local/opt/nvm on Intel Macs):

Terminalbash
mkdir ~/.nvm
export NVM_DIR="$HOME/.nvm"
[ -s "/opt/homebrew/opt/nvm/nvm.sh" ] && \. "/opt/homebrew/opt/nvm/nvm.sh"

Install NVM macOS Using Curl or Wget

The classic way of installing NVM on macOS is by using the curl or the wget command.

Curl

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

Wget

Terminalbash
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.41.0/install.sh | bash

Running either of these commands will automatically update the respective ~/.bash_profile, ~/.zshrc, ~/.profile, or ~/.bashrc files.

Make sure to restart your macOS terminal after the installation has finished or run the source ~/.{yourProfile} command to update your config manually.

Verify Installation

To make sure that NVM has been correctly installed on macOS, run:

Terminalbash
nvm --version
install nvm macos

Install Latest Node.js Version on macOS

To install the latest Node.js version on macOS, run:

Terminalbash
nvm install node
install nvm macos

Install Node.js LTS on macOS

To install the LTS version of Node.js on macOS, run:

Terminalbash
nvm install --lts
nvm use {version}
install nvm macos

Additional Commands

For more commands, check the important NVM commands section at the beginning of this article!

FAQ

Why does my terminal say “nvm: command not found”?

NVM is a shell function, not a program, so your shell has to load it at startup. Restart the terminal or run source ~/.zshrc (or ~/.bashrc). If it still fails, check that the installer added the NVM_DIR lines to the profile file your shell actually reads.

How do I set a default Node.js version?

Run nvm alias default lts/* to open every new terminal on the latest LTS, or nvm alias default node for the latest release. You can also pin a specific version, for example nvm alias default 24.

How do I use a different Node.js version per project?

Create a .nvmrc file in the project root containing a version such as lts/* or 24. Then run nvm use or nvm install inside that folder and NVM reads the file.

Does NVM work on Windows?

Not directly. On Windows you either run NVM inside WSL2 or install nvm-windows, which is a separate project. Its commands differ slightly, for example nvm install lts instead of nvm install --lts.

How do I update NVM?

Run the install script again with the newer version number from the NVM releases page. Your installed Node.js versions stay in place.

Summary

NVM is an excellent tool for managing Node.js versions in your various Web Development projects. If you want to get started with Web Development, make sure to check out our Web Development section.

This should get you up and running no matter on which OS you are. Should you have any kind of problems during the installation, make sure to check the troubleshooting section in the official GitHub repository of NVM.

whoami

Stefan founded Ceos3c in 2016 and has spent a decade teaching cybersecurity, Linux, and web development through hands-on tutorials. He builds and ships real products while sharing his journey: ProofSwap.me, XPMetric.com, and EasyEarningsTracker.com.

More about me