Fix: zsh: command not found: npm after installation (Node.js)


Error:
% npm
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 npm was installed via homebrew.

  1. Open Terminal App.
  2. 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
  3. Refresh your zsh shell by either just typing zsh on the prompt or,
    source ~/.zshrc
  4. Now try the npm command,
    % npm --version
    9.6.7
    

Fix - zsh command not found - npm error
-

Facing issues? Have Questions? Post them here! I am happy to answer!


Author: Rakesh
Author Info:

Rakesh is a seasoned developer with over 10 years of experience in web and app development, and a deep knowledge of operating systems. Author of insightful How-To articles for Code2care.

Follow him on: X

Copyright © Code2care 2023 | Privacy Policy | About Us | Contact Us | Sitemap