Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

brew install npm "npm: command not found"

I've installed node using brew install node and when I use the node -v I get following v5.0.0. However when I try to run the npm command I get npm: command not found.

I've tried to run brew install npm, however I just got following response node-5.0.0 already installed.

It happened with node also returning command not found, but that I fixed by running brew link node, however npm still does not seem to work.

How can I resolve this problem?

like image 844
Peter Pik Avatar asked Oct 12 '22 17:10

Peter Pik


People also ask

How do I fix npm not found?

On Windows, you may face the “npm command not found” error if the path to nodejs and npm are not added to your path variable. To fix this, locate the path to nodejs and npm binaries. The command above should add the specified directory to the path variable.

Why npm is not installing?

The Npm command not found error can appear when you install or upgrade npm. On Windows, the cause of this error could be that a PATH or system variable is not correctly set. The error can also occur if you do not have npm or Node. js installed, have an outdated version, or have permission issues.


2 Answers

I encountered the same issue. After searching and reading different things online, what worked for me was:

$ brew postinstall node

However, first please do execute:

$ brew doctor

and follow the instructions there first, like the comment in your question mentions.

like image 77
mpavel Avatar answered Oct 14 '22 07:10

mpavel


Try running

$ brew postinstall node

If you ever ran sudo npm / sudo yarn, then you might need to change the owner of your global node_modules folder:

$ sudo chown -R "$(id -un)" "${NODE_PATH:-/usr/local/lib/node_modules}"
like image 49
Andreas Louv Avatar answered Oct 14 '22 05:10

Andreas Louv