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


Error:
% 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.

  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

This is not an AI-generated article but is demonstrated by a human on an M1 Mac running macOS Sonoma 14.0.

Please support independent contributors like Code2care by donating a coffee.

Buy me a coffee!

Buy Code2care a Coffee!

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

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