If you build or host Node.js applications, sooner or later you'll run into a project that needs a different Node.js version than the one you already have installed. NVM (Node Version Manager) solves this by letting you install multiple Node.js versions side-by-side and switch between them instantly from the command line — no reinstalling, no conflicts.
What Is NVM?
NVM is a command-line tool that manages Node.js versions per-project instead of system-wide. Without it, you're stuck with whatever single Node.js version is currently installed — which causes problems the moment you work on two projects that require different versions. A project built for Node.js 18 might throw errors or behave unpredictably if you run it on Node.js 22, and vice versa.
With NVM installed, you can install as many Node.js versions as you need and switch between them with a single command, per project or per terminal session.
Before You Begin
If you already have Node.js installed through another method (like an installer downloaded directly from nodejs.org), uninstall it first. Running a standalone Node.js install alongside NVM can cause version conflicts that are confusing to debug.
Installing NVM on Windows
The original NVM project only supports Linux and macOS. On Windows, the community-maintained nvm-windows tool (by developer Corey Butler) provides the same experience. As of this writing, the current stable release is v1.2.2.
Note: the nvm-windows team has announced a successor project called "Runtime" (rt), intended to eventually replace nvm-windows. nvm-windows is still the recommended, actively supported option today — just be aware you may see "Runtime" mentioned if you check the project's GitHub page.
Option 1: Installer (recommended for most users)
- Go to the nvm-windows releases page on GitHub.
- Under the latest release, download the
nvm-setup.exeinstaller. - Run the downloaded installer and complete the setup wizard, accepting the default install location unless you have a specific reason to change it.
- Once installation finishes, open a new Command Prompt or PowerShell window and confirm it worked:
nvm -v
This should print the installed nvm-windows version number. If you get a "command not found" error, close and reopen your terminal — the installer updates your PATH, which only takes effect in new terminal sessions.
Option 2: Package managers
If you already use a Windows package manager, you can install nvm-windows through it instead of downloading the installer manually. As with the installer, open a new terminal window after installing before running nvm.
- winget:
winget install -e --id CoreyButler.NVMforWindows - Chocolatey:
choco install nvm - Scoop:
scoop install nvm(available in Scoop's main bucket — no extra bucket needed)
These are community-maintained packages that track nvm-windows releases, so they can occasionally lag a version or two behind the installer on the GitHub releases page. If a package manager version misbehaves, the installer in Option 1 is the most current source.
Installing NVM on macOS and Linux
Because macOS and Linux are both Unix-based, they use the same install process for standard NVM. The current stable release is v0.40.6.
Option 1: Official install script (recommended)
Step 1: Run the install script
Open your terminal and run one of the following, depending on which tool you have available:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.6/install.sh | bash
or
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.6/install.sh | bash
This clones the nvm repository into a hidden ~/.nvm folder in your home directory.
Step 2: Confirm your shell profile was updated
The install script normally adds the necessary configuration to your shell profile automatically — ~/.zshrc if you use zsh, or ~/.bash_profile/~/.bashrc if you use bash. If it didn't (or you're using a different shell setup), add this block manually:
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
Step 3: Reload your shell
Apply the updated profile without restarting your terminal:
source ~/.bashrc
(Substitute ~/.zshrc if you're using zsh.) Then confirm the install worked:
nvm -v
This should print the installed nvm version.
Option 2: Homebrew (macOS) — not officially supported
Homebrew offers an nvm formula, and you'll see it recommended in a lot of unofficial guides:
brew install nvm
The nvm project's own documentation explicitly does not support Homebrew installs. If you run into issues with a Homebrew-installed nvm, the project's own guidance is to brew uninstall nvm and reinstall using the official script in Option 1 above before troubleshooting further. For that reason, we recommend using Option 1 on macOS rather than Homebrew, even though the formula is available.
Option 3: Linux package managers
Some Linux distributions package nvm through their own package managers (for example, certain community AUR packages on Arch-based systems). These aren't maintained by the nvm project itself, so version freshness and behavior can vary by distro. The official install script in Option 1 is the most consistently up-to-date method across all Linux distributions and is what we'd recommend defaulting to.
Using NVM: The Basics
Once installed, here's how to manage Node.js versions:
- Install the latest Node.js version:
nvm install latest - Install a specific version:
nvm install vX.Y.Z(for example,nvm install v20.11.0) - Set a default version for new terminal sessions:
nvm alias default vX.Y.Z - Switch to a specific version in your current session:
nvm use vX.Y.Z - List installed versions:
nvm list(ornvm ls)
Common Issues
"nvm: command not found" after installing. Close your terminal completely and open a new window — the install process updates your shell profile, which only loads in new sessions.
Old Node.js version still runs after switching. Make sure you didn't also have Node.js installed outside of NVM. A standalone install can take priority in your system PATH over the version NVM is trying to use.
Windows: nvm-windows and a Node.js installer conflict. Fully uninstall any Node.js version installed via the standalone Windows installer before installing nvm-windows, then reinstall your Node.js versions through nvm install instead.
Related Articles / Next Steps
- [Link to an Avalon guide on deploying Node.js applications, if available]
- [Link to an Avalon guide on managing npm packages/dependencies, if available]
- [Link to Avalon's Node.js hosting product page, if applicable]