Upgrade Node.js on macOS

Update Node with its existing installation manager, avoid conflicting paths, and verify the runtime architecture and project compatibility.

Best practices
Illustration of an event loop and asynchronous tasks

First identify what manages your current Node installation. Upgrade through that manager, then confirm the executable, version, and architecture selected by your shell.

command -v node
command -v npm
node --version
npm --version
node -p 'process.arch'

A path under ~/.nvm/versions/node suggests nvm. /opt/homebrew is a common Apple Silicon Homebrew prefix; /usr/local can belong to Intel Homebrew, the official installer, or another tool. Inspect symlinks and package-manager records before deciding which installation to change.

If you use nvm

With nvm loaded in the current shell:

nvm install --lts
nvm use --lts
nvm alias default 'lts/*'

To test the Current release instead, use nvm install node. The --latest-npm option asks nvm to install an appropriate newer npm for the selected Node version; do not assume every newest npm release supports every Node release.

To migrate global packages while installing a new LTS version:

nvm install --lts --reinstall-packages-from=current

Review the migrated tools and their compatibility. nvm keeps versions separate, so switching Node can change which globally installed commands are available. For a project with .nvmrc, follow its declared version rather than overriding it with a moving alias.

If you use Homebrew

brew update
brew list --versions node
brew upgrade node

Those commands address the unversioned node formula. If you installed a versioned formula, use that exact formula name instead. Inspect brew info and follow its PATH instructions; versioned formulas may be keg-only. Do not force-link one version over another merely to make node --version change.

The unversioned formula and LTS release lines are not interchangeable. Check the formula and official Node release information for your intended support policy.

If you used the macOS installer

Download the intended supported release from the official Node.js download page and use its macOS installer. Confirm the resulting paths afterward. If moving to a version manager, plan the migration and remove only files owned by the old installation. Avoid broad deletion or permission changes under /usr/local.

Check Apple Silicon and native dependencies

Current supported releases provide native Apple Silicon builds. The nvm documentation identifies Node 16 as the start of official macOS arm64 packages; older releases can require special handling. A Rosetta terminal and an x64 runtime may be needed for a legacy dependency, but that is a separate compatibility choice, not a reason to mix architectures inadvertently.

After changing architecture or major version, reinstall or rebuild native addons for the target environment and run the project's tests and build. Keep the previous version available until the application and global tools work as expected. If a terminal still sees the old version, inspect PATH ordering and shell startup configuration before installing again.

References

Get a tailored plan

Contact us

Join the community

Scan with WeChat
to join the community

Try Guance

Start online and pay only for what you use.

Get started

Choose a Guance plan

Code hosting