---
title: "How do I switch or upgrade Node.js versions?"
description: "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."
url: https://www.danny.engineering/answer/nodejs/how-do-i-switch-or-upgrade-nodejs-versions
author: Danny
published: 2026-11-27T00:00:00.000Z
updated: 2026-11-27T18:57:00.000Z
tags: ["Node.js"]
---

# How do I switch or upgrade Node.js versions?

## 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:


```bash
nvm install --lts
nvm use --lts
nvm alias default 'lts/*'   # use it in new terminals too
node --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:


```bash
nvm install 24          # install the latest 24.x
nvm use 24              # switch this shell to it
nvm ls                  # list installed versions
nvm alias default 24    # default for new shells
```


When upgrading, nvm can copy your global packages from the old version:


```bash
nvm 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.


```bash
# In ~/.zshrc or ~/.bashrc
eval "$(fnm env --use-on-cd)"
```


```bash
fnm install 24
fnm use 24
fnm 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.


```bash
mise 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.


```bash
echo "24" > .nvmrc
nvm 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 use` and opening a new terminal. `use` only 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 rebuild` or a fresh `npm install`.

## Related reading

- [Node.js: Release schedule](https://nodejs.org/en/about/previous-releases)
- [Node.js: Download and package managers](https://nodejs.org/en/download)
