node.jsbashnpmosx-elcapitan

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?


Solution

  • 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}"