% npm -v
zsh: command not found: npm
If you just installed npm - "node package manager" on your Mac or Unix-like Operating System and you get "command not found" when you run any npm command on your Zsh shell, then the most common reason is that you missed setting the PATH for the npm binary.
Fix: If node/npm was installed via homebrew.
- Open Terminal App.
- Now on the ZSH shell prompt run the below command,
For Intel Chip:export PATH=/usr/local/share/npm/bin:$PATH
For M1/M2 ARM Chip:export PATH=/opt/homebrew/bin/npm/bin:$PATH
- Refresh your zsh shell by either just typing zsh on the prompt or,
source ~/.zshrc
- Now try the npm command,
% npm --version 9.6.7
Facing issues? Have Questions? Post them here! I am happy to answer!
Author Info:
Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.
Follow him on: X
You can also reach out to him via e-mail: rakesh@code2care.org
More Posts related to zsh,
- Resolve - zsh: command not found: code
- zsh: command not found [fix] macOS
- How to fix: zsh: command not found: jupyter
- How to make ZSH as the default shell on Ubuntu
- How to Add New Entry to ZSH PATH
- Add Syntax Highlighting in Zsh Shell
- Fix: zsh: command not found: npm after installation (Node.js)
- Fix: zsh: command not found: mysql (Mac XAMPP)
- Ubuntu zsh: command not found: nano
- Fix: ZSH: cd: too many arguments (macOS)
- Fix - cd: no such file or directory: .zshrc
- How to reload zsh shell profile file?
- Fix zsh: permission denied: script.sh
- [fix] zsh: illegal hardware instruction python TensorFlow M1/M2 Mac
- macOS Ventura 13: The default interactive shell is now zsh
- How to Add Autocomplete in Mac Terminal
- Fix - zsh: command not found: pip
- ZSH: exec format error eclipse M1/M2 Mac
- Setting up Zsh Syntax Highlighting
- How to reload Zsh .zshrc Profile
- zsh: command not found: brew [fix]
- How to clear ZSH history of commands executed on Mac Terminal
- Fix - zsh: command not found: conda [macOS]
- Fix: cd: string not in pwd
More Posts:
- Setting and Updating AWS CLI Configuration - AWS
- List of Special Parameters/Variables in Bash Shell Scripting - Linux
- Convert String from uppercase to lowercase in Bash - Bash
- List all installed packages (Formulae) in Homebrew on Mac - MacOS
- How to repeat background image in Android Activity - Android
- Add days/weeks/months/years to LocalDate in Java 8 and above examples - Java
- How to Open .bash_profile file in Mac Terminal - MacOS
- The tag img may only appear as a descendant of tag noscript. Did you mean amp-img - AMP