This guide assumes a clean install. If you have Node already uninstalled then remove it first.
You can install NVM with brew but it isn't fully supported so go with the official instructions for piece of mind.
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
# or
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
Either open a new shell or refresh your environment.
bash: source ~/.bashrc
zsh: source ~/.zshrc
ksh: . ~/.profile
Check the install.
command -v nvm
nvm
nvm -v
0.40.1
List available versions.
nvm ls-remote
✔
v0.1.14
v0.1.15
v0.1.16
v0.1.17
.......
Install.
# latest
nvm install node
# specific version(s)
nvm install 14.7.0
nvm install 16.3.0, 12.22.1 # multiple versions
Example.
nvm install 22.10.0 127 ✘
Downloading and installing node v22.10.0...
Downloading https://nodejs.org/dist/v22.10.0/node-v22.10.0-darwin-arm64.tar.xz...
########################################################################################################################################## 100.0%
Computing checksum with shasum -a 256
Checksums matched!
Now using node v22.10.0 (npm v10.9.0)
Creating default alias: default -> 22.10.0 (-> v22.10.0)
The first version installed becomes the default.
To set an alias:
nvm alias my_alias v14.4.0
NPM is installed as part of Node.
npm -v ✔ 6s
10.9.0