4Geeks chosen to deliver AI education in the Bahamas alongside Harvard, Oxford, and Columbia.See more

How to install NVM on a Mac OS (node.js and npm)

By 4Geeks

Install nvm 0.41.0 on macOS, load it in zsh, install Node.js 26 LTS and switch versions, on Apple Silicon and Intel.

6 min readLast updated
NVM icon

How do I install NVM on a Mac?

Short answer: open Terminal and run the official script:

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

Then run source ~/.zshrc or open a new terminal, check it with command -v nvm and install Node.js with nvm install --lts. It works on Apple Silicon (M1 to M5) and Intel Macs, and you don't need sudo. You can also use brew install nvm, but the nvm team doesn't support that method.

nvm (Node Version Manager) installs several versions of Node.js in your user folder and switches between them with one command. The latest version is 0.41.0, from November 4, 2026, and nvm install --lts installs Node.js 26, the current LTS.

On a Mac: run the install script, load nvm in zsh and install Node.js 26 LTS.

nvm on Mac at a glance

What you wantCommand
Install nvm (recommended)The official script (step 2)
Install nvm with Homebrewbrew install nvm (see below)
Load it in the current terminalsource ~/.zshrc
Check that it is installedcommand -v nvm
Install the latest LTSnvm install --lts
Install a specific versionnvm install 24
Switch versionnvm use 24
Set the default versionnvm alias default 26
List installed versionsnvm ls

Step 1: prepare your Mac

Since macOS Catalina, the default shell is zsh, and it reads ~/.zshrc. The script adds nvm to that file, but only if it exists. Create it, just in case:

bash
touch ~/.zshrc

The script downloads nvm with git. If your Mac asks you to install the Command Line Tools the first time, accept, or install them yourself with xcode-select --install.

If you already installed Node.js from nodejs.org or with Homebrew, it's better to remove it first (brew uninstall node for Homebrew) so it doesn't get in the way of nvm.

Step 2: run the install script

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

The script clones nvm into ~/.nvm and adds these lines to ~/.zshrc:

bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm

To update nvm later, run the same command with the new version number.

Career · AI Engineering for Developers

Your Mac is ready for Node.js, now build AI apps with it

Use the coding skills you already have to build AI agents, RAG systems and LLM-powered apps, with mentors and real projects.

Step 3: load nvm and check it

The terminal you have open doesn't know nvm yet. Load it, or close and reopen Terminal:

bash
source ~/.zshrc
command -v nvm

If it prints nvm, it is ready. Use command -v and not which: nvm is a shell function, so which nvm prints nothing even when it works. If you still use bash, load ~/.bash_profile instead.

Step 4: install Node.js and switch versions

bash
nvm install --lts
nvm install 24
nvm ls

nvm install --lts installs Node.js 26, the current LTS, with its npm. To switch, and to choose the version every new terminal starts with:

bash
nvm use 24
node -v
nvm alias default 26

nvm use only changes the current terminal. nvm alias default makes the choice stick.

Install nvm with Homebrew

Many people search for brew install nvm. It works, but the nvm team doesn't support it, and you have to add the setup lines yourself:

bash
brew install nvm
mkdir -p ~/.nvm

Then add these lines to the end of ~/.zshrc and run source ~/.zshrc:

bash
export NVM_DIR="$HOME/.nvm"
[ -s "$(brew --prefix nvm)/nvm.sh" ] && \. "$(brew --prefix nvm)/nvm.sh"

brew --prefix nvm returns the right folder on both Apple Silicon (/opt/homebrew/opt/nvm) and Intel (/usr/local/opt/nvm). If something fails, brew uninstall nvm and use the official script.

Install NVM on Mac with AI

An AI assistant such as ChatGPT, Claude or GitHub Copilot can check your shell configuration and read errors for you. These three prompts are ready to copy.

1. Adapt the steps to your Mac

I have a Mac with [Apple Silicon / Intel] and macOS [version]. My shell is [zsh / bash].
I want to install nvm 0.41.0 and Node.js 26 LTS, and keep Node 24 for an old project.
[I already have / I don't have] Node.js installed with [Homebrew / the nodejs.org installer].
Give me the commands one by one and how to check that each one worked.

2. Fix "zsh: command not found: nvm"

I installed nvm on my Mac, but a new terminal says "zsh: command not found: nvm".
I installed it with [the official script / Homebrew]. This is the end of my ~/.zshrc:
[paste the last 15 lines]
Tell me what is missing and how to fix it.

3. Clean up an old Node.js

Before nvm, I installed Node.js with [Homebrew / the nodejs.org installer].
node -v shows [version] and which -a node shows: [paste it]
Tell me whether to remove it and how, so the nvm versions come first.

Read every command before you run it, especially the ones that use sudo or delete files.

Use .nvmrc to fix the Node.js version of a project

Save the version a project needs in an .nvmrc file and commit it to the repository:

bash
cd ~/projects/my-app
node -v > .nvmrc
nvm use

nvm use with no version reads .nvmrc, and nvm install installs that version if it is missing. To install a new version and bring your global packages with you:

bash
nvm install 26 --reinstall-packages-from=24
Learn with a mentor

From setting up Node.js to shipping AI features

In the 4Geeks AI Engineering for Developers program you add AI agents, RAG and production LLM apps to your portfolio.

Common errors with NVM on Mac

What you seeWhy it happensFix
zsh: command not found: nvmThe terminal hasn't loaded nvm, or ~/.zshrc didn't exist when you ran the scriptRun touch ~/.zshrc, run the script again and then source ~/.zshrc
which nvm prints nothingnvm is a shell function, not a programUse command -v nvm to check it
xcrun: error: invalid active developer pathThe Command Line Tools are missing, often after a macOS updateRun xcode-select --install and try again
node -v shows an old versionA Node.js installed with Homebrew or the nodejs.org installer comes firstRun nvm alias default 26, and remove the old Node.js if you don't need it
Each new terminal goes back to another versionNo default version is setRun nvm alias default 26
EACCES: permission denied with npm install -gYou are using a Node.js installed with the system installerUse a Node.js installed with nvm and never run npm with sudo
nvm stops working after brew upgradeThe Homebrew lines in ~/.zshrc point to an old pathUse $(brew --prefix nvm) in ~/.zshrc, or switch to the official script
Free download

NVM on Mac in a 2-page cheat sheet

The install script, Homebrew setup, zsh configuration, every nvm command, .nvmrc, common errors and prompts for ChatGPT, Claude or Copilot. Free, in PDF.

How to install NVM on Mac cheat sheet

2 pages · PDF · 4Geeks

  • The exact commands for Apple Silicon and Intel
  • Script and Homebrew setups side by side
  • Common errors and prompts to solve them with AI

Get it free

Your PDF right away

Frequently asked questions about NVM on Mac

Want to go from setting up Node.js to building AI apps, with real projects and mentors?

See the AI Engineering for Developers program