Running "npm" returns "Error: Cannot find module 'inherits'"

The following worked for me. The other answer, sudo yum install nodejs-inherits*, did not do the trick for me. Note, before running the following, you may want to back up your /usr/lib/node_modules folder so you can refer back to it to recall what all you had installed globally.

sudo yum erase nodejs npm
sudo rm -rf /usr/lib/node_modules
sudo yum install nodejs npm

Hope this helps someone.


I just uninstalled and reinstalled npm:

brew uninstall npm
brew install npm

It didn't go without issue, I also had to reclaim the ownership of some libraries:

sudo chown -R nice /usr/local/lib/node_modules/

and then

brew postinstall npm