NVM Installed: Managing and Switching Node.js Versions

September, 20th 2024 3 min read

Node Version Manager (NVM) is a command-line tool that allows you to install, list, and switch between different versions of Node.js on your operating system. It’s perfect for developers who maintain multiple projects requiring different Node versions.

If you’ve ever seen the message “NVM installed”, this guide will show you how to use NVM effectively — including commands like nvm install latest, nvm ls remote, and nvm alias default.


1. Check Installed Node Versions

To see which Node.js versions are installed on your system, use the command:

nvm list

This will display a list of Node.js versions, marking the default and currently active one.

You can also view all remote versions available for installation:

nvm ls-remote

This command retrieves all versions directly from the Node.js servers.


2. Install a New Node.js Version

To install a specific Node.js version, use the command:

nvm install “version”

For example, to install Node.js v18.20.4:

nvm install 18.20.4

To install the latest LTS version automatically, simply run:

nvm install —lts

Or to get the latest available version overall:

nvm install latest

These commands download and set up the specified version globally within NVM’s environment.


3. Switch Between Node Versions

Once multiple versions are installed, switch between them easily:

nvm use “version”

Example:

nvm use 20.17.0

This activates Node.js version 20.17.0 for your current terminal session.

If you want to confirm which version is active, run:

node -v

4. Set a Default Node.js Version

To make a specific Node.js version the default every time you open a new terminal, use:

nvm alias default “version”

Example:

nvm alias default 18.20.4

Now, each new session will automatically use that version unless overridden.


5. Uninstall a Node Version

If you want to remove an older version, you can do so easily:

nvm uninstall “version”

Example:

nvm uninstall 12.22.1

This will delete the specified version from your system while leaving other installations intact.


6. Common NVM Commands Overview

CommandDescription
nvm install latestInstalls the most recent Node.js version
nvm install --ltsInstalls the latest LTS release
nvm lsLists all Node.js versions installed locally
nvm ls-remoteLists all Node.js versions available remotely
nvm alias defaultSets a default Node version for all sessions
nvm uninstallUninstalls a specific version of Node.js
nvm currentDisplays the currently active version

7. Troubleshooting and Tips

  • Always run NVM commands from your command line or terminal, not from scripts that bypass shell configuration.
  • If NVM seems not to work after installation, ensure your shell profile (like .bashrc or .zshrc) includes the NVM initialization line.
  • You can verify NVM installation with:
command -v nvm

If it returns nvm, the tool is correctly installed.


8. Why Use NVM?

Using NVM helps you:

  • Test your apps on multiple Node.js versions.
  • Prevent dependency conflicts across projects.
  • Simplify team collaboration when using different Node environments.

It works on macOS, Linux, and Windows (via WSL), giving you a unified way to manage Node.js version numbers across your operating systems.


✅ Updated for NVM v0.39+ — compatible with Node.js 22 and later