How to Brew Install Specific Version of Node?

Avoid using the latest Node.js if not needed. Use Homebrew to install specific versions like node@18 and manage your PATH settings.

How to Brew Install Specific Version of Node?
Install a specific Node.js version on macOS with brew install node@<version> or nvm. Make sure to link manually and manage PATH for usage.

Problem

On macOS developers want to install or switch to a specific Node.js version. Using Homebrew’s default install command always installs the latest version which might not be compatible with your app or tooling.

Solution

Use Node Version Manager (nvm) for more control or install specific versions via Homebrew with the node@<version> formula.

Option 1- Use nvm

bash
brew install nvmnvm install 18 nvm use 18

Option 2- Install a specific version via Homebrew

bash
brew install node@18To link it manually:

bash

brew link --overwrite --force node@18
Also Read: Building A Node JS MVC Application

Set PATH if needed

bash
export PATH="/opt/homebrew/opt/node@18/bin:$PATH"
You can now check:

bash

node -v
For long term use add the path export to your shell profile (e.g., .zshrc or .bash_profile).

Conclusion

Use nvm for flexibility or brew install node@<version> for targeted installs. Always verify your path and version with node -v.

Want to Accelerate your NodeJS Solution?

Partner with our Skilled NodeJS Developers to build, scale, and achieve Robust Node Solutions.