Use a version manager such as nvm, fnm or mise to install several Node.js versions side by side and switch per project. Learn the commands and how .nvmrc pins a version.
The short answer
#Install Node.js through a version manager rather than the installer from the website. A version manager keeps several versions side by side and lets you switch with one command. With nvm, installing and switching to the current LTS release looks like this:
_10nvm install --lts_10nvm use --lts_10nvm alias default 'lts/*' # use it in new terminals too_10node --version
Then add a .nvmrc file to each project so everyone uses the same version.
Why it happens
#The Node.js installer puts one version in a system location. Upgrading replaces it for every project on your machine, and older projects that need a different major version break. Installing global packages there can also need sudo.
Projects move at different speeds. As of late 2026, Node.js 26 and 24 are LTS, 22 is in maintenance until April 2027, and 20 has reached end of life. A version manager installs each version into your home folder and changes which node your shell finds on the PATH, so switching is instant and nothing needs admin rights.
How to fix it
#nvm (macOS, Linux, WSL)
nvm is the most widely used option and is a shell script, so it works anywhere Bash or Zsh does. Install it with the command from the nvm README, then:
_10nvm install 24 # install the latest 24.x_10nvm use 24 # switch this shell to it_10nvm ls # list installed versions_10nvm alias default 24 # default for new shells
When upgrading, nvm can copy your global packages from the old version:
_10nvm install 26 --reinstall-packages-from=24
On Windows, nvm-windows is a separate project with similar but not identical commands.
fnm (fast, cross-platform)
fnm is written in Rust, starts quickly and works on Windows, macOS and Linux. Add its shell setup to your profile so it switches automatically when you cd into a project with a version file.
_10# In ~/.zshrc or ~/.bashrc_10eval "$(fnm env --use-on-cd)"
_10fnm install 24_10fnm use 24_10fnm default 24
mise (several languages in one tool)
mise manages Node.js alongside other runtimes such as Python or Go, and writes the version to a mise.toml file in the project.
_10mise use node@24
If you use Volta, note that its maintainers have marked it as unmaintained and recommend moving to mise. Existing setups keep working, but it is not a good choice for new machines.
Pin the version per project
Create a .nvmrc (or .node-version) file containing the major version. nvm reads .nvmrc when you run nvm use with no argument, and fnm and mise read both files.
_10echo "24" > .nvmrc_10nvm use
Commit the file. Many CI setups, including actions/setup-node on GitHub Actions, can read it too, so local and CI builds match.
Remove the system install
If node --version still shows the old version after switching, a system install or Homebrew copy is earlier on your PATH. Check with which -a node and uninstall the extra copy.
Common pitfalls
#- Expecting global packages to follow you. Each version has its own globals, so reinstall them or use the copy option when you upgrade.
- Running
nvm useand opening a new terminal.useonly affects the current shell; set a default as well. - Mixing two version managers. Their shims fight over the
PATH; pick one. - Skipping straight past several major versions on an old project. Read the breaking changes for each major release in between.
- Rebuilding nothing after an upgrade. Packages with native add-ons may need
npm rebuildor a freshnpm install.
Related reading
#Was this resource helpful?