Languages

Switch Node.js versions with nvm

Install several Node.js versions side by side and switch between them per project.

Fill these in once
  1. Install nvm
    Terminal
    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash

    Remove any Node.js you installed with Homebrew first (brew uninstall node), so the two don't clash.

  2. Load nvm into this terminal
    Terminal
    source ~/.zshrc
  3. Install a version and switch to it
    Terminal
    nvm install 22 && nvm use 22
  4. Make it the default for new terminals
    Terminal
    nvm alias default 22

Check it worked

  1. See the versions you have and which one is active
    Terminal
    nvm ls && node --version
Undo it
  1. Remove a version
    Terminal
    nvm deactivate && nvm uninstall 22
  1. Install nvm
    Terminal · Ubuntu / Debian
    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
  2. Load nvm into this terminal
    Terminal · Ubuntu / Debian
    source ~/.bashrc
  3. Install a version and switch to it
    Terminal · Ubuntu / Debian
    nvm install 22 && nvm use 22
  4. Make it the default for new terminals
    Terminal · Ubuntu / Debian
    nvm alias default 22

Check it worked

  1. See the versions you have and which one is active
    Terminal · Ubuntu / Debian
    nvm ls && node --version
Undo it
  1. Remove a version
    Terminal · Ubuntu / Debian
    nvm deactivate && nvm uninstall 22
  1. Install nvm for Windows
    PowerShell
    winget install CoreyButler.NVMforWindows

    Uninstall any other Node.js first, then close and reopen PowerShell.

  2. Install a version
    PowerShell
    nvm install 22
  3. Switch to itRun as administrator
    PowerShell
    nvm use 22

Check it worked

  1. See the versions you have and which one is active
    PowerShell
    nvm list; node --version
Undo it
  1. Remove a version
    PowerShell
    nvm uninstall 22