Blog
3 min read

What Is nvm? Install and Switch Node.js Versions the Easy Way

nvm (Node Version Manager) lets you install several versions of Node.js and switch between them per project. How to install it on Mac and Linux, the Windows options, the commands you'll actually use, .nvmrc files, and alternatives like fnm and Volta.

nvm — Node Version Manager — is a small tool that lets you install multiple versions of Node.js and switch between them with one command.

Why would you need more than one? Because projects pin different versions. An older app might need Node 22, a new one Node 26, and a tutorial you're following might expect something else. Installing Node directly from nodejs.org gives you one global version; nvm gives you as many as you like.

Install nvm (Mac and Linux)

Use the install script from the official nvm repository — copy the current command from its README, which looks like:

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

Then close and reopen your terminal (or source ~/.zshrc). Check it worked:

nvm --version

Windows

The original nvm doesn't run on Windows. Your options:

  • nvm-windows, a separate project with similar commands.
  • fnm or Volta (below), which work natively on Windows.
  • WSL, where the normal Linux nvm works. (What Is WSL?)

The commands you'll actually use

nvm install --lts      # install the latest long-term-support version
nvm install 24         # install the latest Node 24
nvm use 24             # switch this terminal to Node 24
nvm ls                 # list installed versions
nvm alias default 24   # make 24 the default for new terminals
node --version         # confirm which one is active

Each Node version gets its own global packages. If you installed a CLI tool globally under Node 22 and switch to 24, reinstall it — or use nvm install 24 --reinstall-packages-from=22.

Pin a version per project with .nvmrc

Create a file called .nvmrc in your project with the version in it:

24

Now anyone (including your server and Claude Code) can run:

nvm use

and get the right version. Commit .nvmrc to git. You can also declare it in package.json for tools and hosts that read it:

"engines": { "node": ">=24" }

Which version should you use?

Use an LTS (long-term support) version for real projects — even-numbered releases like 22, 24 and 26 become LTS. Node 26 becomes the Active LTS in late October 2026, with Node 24 moving to maintenance. Odd-numbered versions are short-lived. (Node vs Bun vs Deno)

Alternatives

  • fnm — "Fast Node Manager", written in Rust; very quick, works on Windows, reads .nvmrc.
  • Volta — pins the Node version in package.json and switches automatically when you cd into the project.
  • mise / asdf — manage versions of many languages (Node, Python, Ruby) with one tool.

Common problems

  • nvm: command not found after installing — reopen the terminal, or check the install script added lines to your ~/.zshrc or ~/.bashrc. (Zsh vs Bash)
  • Version resets in a new terminal — set a default with nvm alias default.
  • sudo npm install -g errors — with nvm you never need sudo for global packages. (npm EACCES Permission Denied)

The summary

  • nvm installs multiple Node.js versions and switches between them.
  • nvm install, nvm use, nvm alias default are most of what you need.
  • Pin each project's version with .nvmrc.

EasySpawn servers come with Node ready and let Claude Code install the exact version your project's .nvmrc asks for, so local and production match. See how it works or join the waitlist.

Related: npm and package.json Explained · npm vs pnpm vs Yarn vs Bun · What Is Homebrew? · Terminal for Beginners

Keep reading