Encountering "zsh: command not found: node" is a common blocker for developers who rely on modern JavaScript tooling. This error appears when your shell cannot locate the Node.js executable in the directories listed in your PATH.
While the message is straightforward, the underlying cause can vary across machines, from simple installation issues to misconfigured environment variables. The following sections outline the most effective ways to diagnose and resolve this specific zsh error.
| Symptom | Likely Cause | Priority | Fix Complexity |
|---|---|---|---|
| zsh: command not found: node | Node.js is not installed | High | Low |
| node works in new terminal but not current session | PATH not updated in shell config | Medium | Low |
| command not found after reinstall | Installation path missing from PATH | High | Medium |
| node found but npm fails | Partial installation or symlink issues | Medium | Medium |
Verify Node.js Installation
Before debugging PATH variables, confirm whether Node.js is actually present on your system. Sometimes the command is not found simply because the runtime was never installed or was removed accidentally.
Check for existing installation
You can quickly verify if Node.js exists by searching common installation directories or by asking your package manager for status. This step saves time and prevents redundant installations.
Configure Shell PATH for zsh
Zsh strictness means environment variables must be defined in the right configuration file. If Node.js is installed but not in a directory listed in PATH, zsh will report "command not found" every time you try to run node.
Locate the Node.js binary
Use find or mdfind to discover where node is installed, then ensure that parent directory is exported in your PATH. Common paths include /usr/local/bin, /opt/homebrew/bin, or directories created by version managers like nvm.
Update .zshrc permanently
Open your ~/.zshrc file, append the correct export line such as export PATH="/usr/local/bin:$PATH", and source the file. This adjustment makes node accessible in all future terminal sessions.
Use Version Managers like nvm
Node Version Manager (nvm) sidesteps permission and path conflicts by installing Node.js in your user directory. This approach is ideal when you need to switch between Node.js versions without sudo privileges.
Install nvm and node
After installing nvm, run nvm install node to get the latest version. Nvm automatically updates PATH and ensures that node and npm commands are found in your current shell session.
System Path Troubleshooting
System-level PATH misconfigurations can break node access even when the runtime is correctly installed. Inspecting your entire PATH and checking shell startup files helps isolate the problem.
Audit current PATH
Run echo $PATH and compare the listed directories against the actual location of node. If node lives in a missing path, add that directory to your PATH using export or by modifying your shell profile.
Check for conflicting tools
Package managers such as Homebrew or manual tarball installs may place node in different directories. Verify which node is active with which node and adjust your PATH order or uninstall conflicting versions accordingly.
Recommended Actions and Best Practices
- Confirm Node.js installation with your package manager or by locating the binary manually.
- Ensure the directory containing node is exported in PATH inside ~/.zshrc.
- Use nvm for per-user installations to avoid permission issues and simplify version management.
- Audit PATH ordering so that Node.js directories appear before generic system paths.
- Source your shell configuration or restart the terminal after changes to apply updates.
FAQ
Reader questions
Why does node work in a new terminal window but not in my current session?
Your shell startup files may not have been re-sourced after editing .zshrc. Open a new terminal or run source ~/.zshrc to reload the PATH configuration.
Can I fix zsh: command not found: node by reinstalling Node.js?
Yes, but only if the installation was corrupted. Use the official installer or a package manager to reinstall, then verify that the binary path is included in your PATH.
What should I do if npm works but node does not?
This usually indicates a broken symlink or a PATH entry pointing to the npm script but not the node binary. Reinstall Node.js via nvm or your system package manager to restore both components.
Is it safe to modify /usr/local/bin to fix this issue?
Only adjust system directories if you understand the risks. Prefer user-level installations with nvm or adjust PATH to include the correct directory rather than forcing symlinks in system paths.