What Is NVM? Node Version Manager Explained for Beginners
NVM (Node Version Manager) is a command-line tool that lets you install, manage, and switch between multiple versions of Node.js on a single machine. Instead of uninstalling and reinstalling Node.js every time a project requires a different version, NVM lets you run nvm use 18 or nvm use 20 to switch instantly. It is the most widely used Node.js version manager on macOS and Linux, with over 80,000 GitHub stars.
What Is NVM (Node Version Manager)?
NVM solves a fundamental problem every JavaScript developer eventually faces: different projects need different Node.js versions. A legacy application might depend on Node.js 16 features, while a newer project requires Node.js 22. Without a version manager, you are stuck manually downloading installers or rewriting your system PATH every time you switch projects.
With NVM installed, managing Node.js versions becomes as simple as:
nvm install 20 # Download and install Node.js 20
nvm use 20 # Switch to Node.js 20 in the current shell
nvm install 22 # Download and install Node.js 22
nvm use 22 # Switch to Node.js 22
node --version # Confirms v22.x.x
Each version is stored in its own directory (~/.nvm/versions/node/), and NVM updates your shell’s PATH to point to the correct one. There is no conflict between versions, and you can have as many installed simultaneously as you need.
Note: The abbreviation “NVM” also appears in informal online chat as short for “never mind.” In the developer context, NVM always refers to Node Version Manager.
Why You Need a Node.js Version Manager
If you only ever work on one project, a single global Node.js installation might be fine. But in practice, most developers encounter these scenarios quickly:
- Project compatibility — An older project breaks on the latest Node.js because deprecated APIs were removed. A newer project requires features only available in recent releases.
- Team consistency — Your team agrees on Node.js 20 LTS for production. Without a version manager, someone inevitably runs a different version locally and introduces subtle bugs.
- Testing across versions — Library maintainers need to verify their packages work on Node.js 18, 20, and 22. NVM lets you test against each without separate machines or containers.
- Avoiding permission issues — Installing Node.js from the official installer often requires
sudofor global packages. NVM installs everything in your home directory, sonpm install -gnever needs elevated permissions.
Without NVM, you would need to manually download different Node.js tarballs, update your PATH, and keep track of which version is active. NVM automates all of this with a single command. For a broader comparison of how NVM fits alongside NPM and Node.js itself, see NVM vs NPM vs Node.js.
How NVM Works
NVM is a POSIX-compliant shell script (written in bash). When you source it in your shell profile (.bashrc, .zshrc, etc.), it provides the nvm command. Here is what happens under the hood:
- Installation of a version —
nvm install 20downloads the official Node.js binary for your platform and extracts it to~/.nvm/versions/node/v20.x.x/. - Switching versions —
nvm use 20updates thePATHenvironment variable in your current shell session so thatnode,npm, andnpxall point to the v20 binary. - Default version —
nvm alias default 20sets which version activates automatically in every new terminal session. - Per-project version — If a project contains an
.nvmrcfile with a version number (e.g.,20), runningnvm usein that directory automatically selects the correct version.
Because NVM modifies only shell environment variables, it has no system-wide side effects. Each terminal session can run a different Node.js version independently.
The .nvmrc File
Creating an .nvmrc file in your project root is a best practice for team collaboration:
echo "20" > .nvmrc
When a team member clones the repository and runs nvm use, NVM reads the file and switches to the specified version. If they don’t have it installed, nvm install (with no arguments) will read .nvmrc and install the correct version automatically.
NVM on Different Operating Systems
macOS and Linux
The original NVM project (nvm-sh/nvm on GitHub) supports macOS and Linux natively. Installation is a single curl command:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
After installation, restart your terminal or run source ~/.bashrc (or ~/.zshrc) to load NVM.
Windows
The original NVM does not support Windows. Windows users have two recommended options:
- nvm-windows — A separate project by coreybutler that reimplements NVM’s functionality as a native Windows executable. Install it from github.com/coreybutler/nvm-windows. Commands are nearly identical (
nvm install 20,nvm use 20). - fnm — A modern alternative written in Rust that works on all platforms (macOS, Linux, and Windows) with a single binary. See the fnm commands guide for full details.
WSL (Windows Subsystem for Linux)
If you use WSL on Windows, you can install the original NVM exactly as you would on Linux. This is often the simplest approach for developers who already use WSL for their development environment.
Getting Started with NVM
Here is a quick-start workflow after installation:
# Check NVM is installed
nvm --version
# List available Node.js versions for download
nvm ls-remote
# Install the latest LTS version
nvm install --lts
# Install a specific version
nvm install 20
# See which versions are installed locally
nvm ls
# Switch to a specific version
nvm use 20
# Set a default version for new terminal sessions
nvm alias default 20
# Uninstall a version you no longer need
nvm uninstall 16
Common Commands at a Glance
| Command | Description |
|---|---|
nvm install <version> | Download and install a Node.js version |
nvm use <version> | Switch to an installed version |
nvm ls | List locally installed versions |
nvm ls-remote | List all available versions |
nvm alias default <version> | Set the default version |
nvm current | Show the currently active version |
nvm uninstall <version> | Remove an installed version |
Verifying Your Setup
After switching versions, confirm everything works:
node --version # Should show v20.x.x (or whichever version you selected)
npm --version # NPM comes bundled with Node.js
which node # Should point to ~/.nvm/versions/node/...
NVM vs fnm: Which Should You Choose?
NVM has been the default choice for years, but fnm (Fast Node Manager) is a modern alternative worth considering:
| Feature | NVM | fnm |
|---|---|---|
| Language | Bash script | Rust binary |
| Shell startup | ~100ms+ | < 1ms |
| Windows support | No (needs nvm-windows) | Yes (native) |
| Auto-switching | Requires plugin/hook | Built-in (--use-on-cd) |
| .nvmrc support | Yes | Yes |
| Command syntax | nvm install/use/ls | fnm install/use/ls |
Choose NVM if you want maximum ecosystem compatibility, extensive documentation, and don’t mind the slight shell startup delay. NVM has been the community standard since 2010.
Choose fnm if you want faster terminal startup, native Windows support without a separate tool, and built-in auto-switching. The commands are nearly identical, so switching from NVM to fnm takes minutes. Read the full fnm commands guide for a detailed walkthrough.
Summary
NVM (Node Version Manager) is an essential tool for any JavaScript developer working with Node.js. It lets you install multiple Node.js versions side by side, switch between them instantly, and keep your projects isolated from each other. Whether you choose the original NVM or a faster alternative like fnm, using a version manager eliminates an entire class of “it works on my machine” problems and makes collaboration significantly smoother.
Further reading:
Software developer passionate about technology. Sharing programming experiences and learning notes.