How to Upgrade Node Version on Mac Using Homebrew: The Complete Guide
Run brew update && brew upgrade node in your terminal to upgrade Node.js to the latest stable version on macOS, then verify the installation with node -v.
When you need to upgrade node version mac systems that originally used Homebrew for installation, the process is remarkably straightforward. Homebrew maintains a dedicated node formula in its core repository that tracks official releases from the nodejs/node GitHub repository, allowing you to manage upgrades through simple command-line instructions without manual compilation or path manipulation.
Why Homebrew Is the Preferred Method to Upgrade Node Version on Mac
Homebrew simplifies upgrade node version mac workflows by abstracting the complexity of building Node.js from source. The node formula in Homebrew’s core tap defines exactly how to download, compile, and install Node.js from the official source tarball—the same source code that lives in the nodejs/node repository.
When you upgrade, Homebrew manages link management automatically. It maintains symlinks in /usr/local/opt/node on Intel Macs or /opt/homebrew/opt/node on Apple Silicon systems. During an upgrade, Homebrew rewrites these links to point to the new version, ensuring that any node or npm command immediately uses the updated binary without requiring manual path changes.
Step-by-Step Guide to Upgrade Node Version on Mac
Follow these commands in your terminal to complete the upgrade node version mac process safely.
Update Homebrew’s Formula List
First, refresh Homebrew’s local database to ensure it knows about the latest Node.js releases.
brew update
This command pulls the latest formula definitions from Homebrew’s core repository, updating the node formula to point to the newest release published by the Node.js project.
Upgrade to the Latest Node.js Release
Execute the upgrade command to download and install the latest stable version.
brew upgrade node
Homebrew downloads the newest Node.js source tarball (or a pre-built "bottle" if available for your CPU architecture), builds it if necessary, and replaces the currently linked version. This step handles the core upgrade node version mac operation.
Verify the Installation
Confirm that your system now uses the updated binaries.
node -v && npm -v
You should see output displaying the latest version numbers (for example, v22.0.0 for Node.js and 10.5.0 for npm).
Clean Up Old Versions (Optional)
Remove previous build artifacts and outdated Cellar directories to free disk space.
brew cleanup node
This command deletes old versions stored in Homebrew’s Cellar, keeping your system tidy without affecting the current installation.
Installing Specific LTS Versions on Mac
If you require a specific Long Term Support (LTS) version rather than the latest stable release, Homebrew provides versioned formulas.
Install a specific LTS track (for example, Node.js 20.x):
brew install node@20
Link the versioned formula to make it your active Node.js installation:
brew link --overwrite --force node@20
Verify the specific version:
node -v
This approach allows you to upgrade node version mac systems to specific LTS releases while maintaining the convenience of Homebrew’s package management.
Key Files in the Node.js Repository
The following files in the nodejs/node repository provide context for the source code that Homebrew compiles during your upgrade:
README.md– Provides a high-level overview of the project, licensing information, and contribution guidelines.doc/changelogs/CHANGELOG_V22.md– Lists changes introduced in the current major version, useful for reviewing what’s new after an upgrade.doc/contributing/building-node-with-ninja.md– Describes building Node.js from source, including optional Homebrew tools such asmakeandccache.tools/gyp/pylib/gyp/xcode_emulation.py– Contains logic borrowed from Homebrew’s Command Line Tools (CLT) version check, demonstrating how the repository interacts with Homebrew tooling.deps/uv/README.md– Documents the libuv dependency (which Node.js bundles) and notes that it can alternatively be installed via Homebrew.
These files illustrate the relationship between the Node.js source code and the Homebrew installation pathway.
Summary
- Use
brew update && brew upgrade nodeas the most straightforward method to upgrade node version mac systems that originally used Homebrew. - Homebrew manages symlinks automatically in
/usr/local/opt/node(Intel) or/opt/homebrew/opt/node(Apple Silicon), ensuring immediate access to new binaries. - Verify upgrades with
node -vand clean old versions usingbrew cleanup node. - Install specific LTS releases using versioned formulas like
node@20when you need stability over the latest features. - The nodejs/node repository files such as
doc/changelogs/CHANGELOG_V22.mdanddoc/contributing/building-node-with-ninja.mdprovide technical context for the source code Homebrew compiles.
Frequently Asked Questions
How do I check my current Node.js version before upgrading?
Run node -v in your terminal. This displays the currently active version (for example, v18.17.0). You can also run which node to confirm whether Homebrew manages your installation—the path should point to /usr/local/bin/node (Intel) or /opt/homebrew/bin/node (Apple Silicon).
Can I have multiple Node.js versions installed simultaneously on macOS?
Yes. Homebrew supports side-by-side installations using versioned formulas such as node@18, node@20, and node@22. Only one version can be linked as the default node command at a time, which you manage using brew link and brew unlink. Alternatively, tools like nvm or fnm provide more granular version switching without relying on Homebrew’s linking system.
What should I do if brew upgrade node fails?
First, run brew doctor to identify any system configuration issues that might block the upgrade. Check that Xcode Command Line Tools are installed and up to date, as the nodejs/node repository requires them for compilation (referenced in doc/contributing/building-node-with-ninja.md). If the failure persists, try brew reinstall node to force a fresh build, or consult the specific error logs in ~/Library/Logs/Homebrew/node/ to diagnose compilation errors related to the source tarball.
Is upgrading Node.js via Homebrew safe for production environments?
Upgrading via Homebrew is generally safe for development machines, but production environments require additional caution. Homebrew typically installs the latest stable version, which may introduce breaking changes not present in LTS releases. For production servers, prefer installing specific LTS versions using brew install node@20 (or your target LTS), and always test your application against the new version in a staging environment first. Review the doc/changelogs/CHANGELOG_V22.md (or relevant version) in the nodejs/node repository to audit breaking changes before deploying.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →