187 words
1 minutes
Fastest Way to Install Node.js 22 with nvm on Mac

Why nvm?#

  • Instant switching: Use nvm use 22 or .nvmrc to lock versions per project.
  • No sudo needed: Installs in user space, keeping your system Node clean.
  • Reproducible: Share .nvmrc so everyone uses the same Node version.

Installation Steps#

1) Install nvm (Official Installer)

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

Check GitHub for the latest command.

After installation, verify initialization in ~/.zshrc. If missing, add:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"

Then reload:

source ~/.zshrc

To check for hidden files:

ls -a

nvm setup verification

2) Install and Use Node.js 22

nvm install 22
nvm use 22
node -v   # v22.x
npm -v    # 10.x+

(Optional) Set 22 as default:

nvm alias default 22

3) Lock Version Per Project

echo "22" > .nvmrc
nvm use   # Automatically selects v22 in this directory

Common Issues#

  • nvm: command not found → Check ~/.zshrc initialization and run source ~/.zshrc.
  • Not switching to v22 → Run which node to see if Homebrew’s Node takes priority. If needed, brew uninstall node.
  • Global npm not working → Verify npm prefix -g bin is in PATH (only if needed).

Final Notes#

It would be easier if Homebrew installation worked, but nvm doesn’t seem to support it. Manual setup is a bit tedious, but it’s the way to go.

Fastest Way to Install Node.js 22 with nvm on Mac
https://naonao-na.com/en/posts/nodejs-install-nvm-mac/
Author
[object Object]
Published at
2025-10-13