Global Node modules not installing correctly. Command not found

Solution 1:

This may mean your node install prefix isn't what you expect.

You can set it like so:

npm config set prefix /usr/local

then try running npm install -g again, and it should work out. Worked for me on a mac, and the solution comes from this site:

http://webbb.be/blog/command-not-found-node-npm/

EDIT: Note that I just came across this again on a new Mac I'm setting up, and had to do the process detailed here on stackoverflow as well.

Solution 2:

Add $(npm get prefix)/bin to your PATH (e.g., in .bashrc), like so:

echo "export PATH=$PATH:$(npm get prefix)/bin" >> ~/.bashrc

For more info, see npm help npm:

global mode: npm installs packages into the install prefix at prefix/lib/node_modules and bins are installed in prefix/bin.

You can find the install prefix with npm get prefix or npm config list | grep prefix.