Nodejs Command Not Found After Brew Install: Fixing macOS PATH Issues

If the node command is not found after running brew install node, your shell PATH does not include Homebrew's installation directory, typically /opt/homebrew/bin on Apple Silicon or /usr/local/bin on Intel Macs.

When you install Node.js via Homebrew on macOS, the package manager downloads and compiles the runtime from the nodejs/node repository. However, the installation does not automatically modify your shell's environment variables on all systems, leaving the node and npm binaries inaccessible from the command line until you manually update your PATH.

Why Brew Install Node Does Not Always Update Your PATH

Homebrew installs binaries to different locations depending on your Mac architecture. The installer attempts to add these locations to your PATH, but this step often fails if your shell configuration files lack the proper initialization commands or if you are using a non-standard shell.

Apple Silicon vs Intel Installation Paths

Homebrew uses different prefix directories for Apple Silicon (ARM) and Intel (x86) Macs:

  • Apple Silicon (M1/M2/M3): /opt/homebrew/bin
  • Intel Macs: /usr/local/bin

If you migrated from an Intel Mac to Apple Silicon using Migration Assistant, your shell might still reference the old Intel paths, causing the node command to fail even after a fresh brew install node.

Shell Configuration File Conflicts

macOS Catalina and later use Zsh as the default shell, while older systems use Bash. Homebrew's installation instructions differ for each:

  • Zsh: Requires modifications to ~/.zprofile
  • Bash: Requires modifications to ~/.bash_profile

If you install Node.js while running Bash but later switch to Zsh, or if you have configuration commands in .bashrc instead of .bash_profile, the PATH updates will not persist across new terminal sessions.

How to Fix Nodejs Command Not Found After Brew Install

To resolve the issue, you must manually add Homebrew's binary directory to your shell's PATH environment variable and reload your configuration.

Solution 1: Configure PATH for Zsh (Default on macOS Catalina+)

Run the following commands to add Homebrew to your Zsh environment:

echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"

The first command appends the Homebrew initialization script to your ~/.zprofile, ensuring it runs for every new login shell. The second command executes it immediately in your current session.

Solution 2: Configure PATH for Bash (Legacy Systems)

If you are using Bash on an Intel Mac or have manually switched to Bash, use:

echo 'eval "$(/usr/local/bin/brew shellenv)"' >> ~/.bash_profile
eval "$(/usr/local/bin/brew shellenv)"

After running these commands, close and reopen your terminal, or run source ~/.bash_profile to apply the changes.

If the PATH is correct but node is still not found, the Homebrew linking step may have failed. Run:

brew doctor
brew link node

The brew doctor command diagnoses common issues, while brew link node creates the symbolic links in /opt/homebrew/bin (or /usr/local/bin) pointing to the actual Node.js installation directory, typically /opt/homebrew/Cellar/node/ followed by the version number.

Verifying Your Node.js Installation

After updating your PATH, confirm that the node binary is accessible and executable:

which node

This should output /opt/homebrew/bin/node on Apple Silicon or /usr/local/bin/node on Intel systems.

Check the installed version to ensure the binary runs correctly:

node --version

If both commands return expected values, the nodejs command not found error is resolved, and the runtime from the nodejs/node repository is properly integrated into your system.

Summary

  • Homebrew installs Node.js to architecture-specific directories (/opt/homebrew for Apple Silicon, /usr/local for Intel) but does not always update your shell PATH automatically.
  • The fix requires adding eval "$(brew shellenv)" to your shell profile (~/.zprofile for Zsh, ~/.bash_profile for Bash) to export the correct binary path.
  • Verification involves running which node and node --version to confirm the symlink exists in your PATH and the binary executes correctly.

Frequently Asked Questions

Why is node not found after brew install on M1 Mac?

On Apple Silicon Macs (M1/M2/M3), Homebrew installs to /opt/homebrew/bin, which is not included in the default macOS PATH. You must manually add this location to your ~/.zprofile using the brew shellenv command, then restart your terminal.

Do I need to restart my terminal after fixing the PATH?

Yes, you must restart your terminal or open a new tab for the updated ~/.zprofile or ~/.bash_profile to take effect. Alternatively, you can run source ~/.zprofile (or source ~/.bash_profile) to apply the changes to your current session immediately.

Can I install Node.js without Homebrew on macOS?

Yes, you can download the official macOS installer from the Node.js website, use a version manager like nvm (Node Version Manager), or install via MacPorts. These methods may handle PATH configuration differently or install to locations already in your default PATH.

What is the difference between node and nodejs commands?

The standard command for the Node.js runtime is node. Some Linux distributions use nodejs to avoid conflicts with an older package, but Homebrew and the official nodejs/node repository use node. If your system expects nodejs, you can create an alias: alias nodejs='node'.

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:

Share the following with your agent to get started:
curl -s https://instagit.com/install.md

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client