NPM Command Not Found After Installing Node

Nicholas Haley picture Nicholas Haley · Sep 23, 2015 · Viewed 91.8k times · Source

I am having a very hard time getting the npm command to work, and unfortunately my knowledge of unix isn't good enough to solve this on my own. All I've done is brew install node, and I get the following errors:

When I type npm I get zsh: command not found: npm

Looking into this issue more I found this stack overflow answer:

Command not found after npm install in zsh

Following its advice I tried adding export PATH=/usr/local/share/npm/bin:$PATH to my .zshrc file. Still get the same error when typing npm

I can confirm it is in the path echo $PATH yields /Users/nicholashaley/.rbenv/shims:/Users/nicholashaley/.rbenv/bin:/Applications/Postgres.app/Contents/Versions/9.3/bin:/usr/local/heroku/bin:/usr/local/share/npm/bin:/usr/local/bin:/Applications/Postgres.app/Contents/Versions/9.3/bin:/usr/local/heroku/bin:/Users/nicholashaley/.rbenv/shims:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin

I can also confirm that node has been installed node -v yields v0.12.2

Any ideas? I'm stumped

Answer

Adrian Lynch picture Adrian Lynch · Sep 23, 2015

Not an answer, but maybe a solution...

Uninstall Node via brew: brew uninstall node

Then download Node from https://nodejs.org/en/download/ and install.

npm should then "just work".