Running “npm” returns “Error: Cannot find module 'inherits'”

久未见 提交于 2019-12-05 04:32:01

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.

Nico

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

To share my info, I faced this issue, and I solved it by installing inherits as the following:

sudo npm install inherits

This the github repo of it.

sudo yum install nodejs-inherits* didn't work for me. Also I didn't want to erase node_modules.

Erasing inherit modules and installing/reinstalling only the new one worked:

sudo yum erase nodejs-inherits
sudo yum erase nodejs-inherits1
sudo yum install nodejs-inherits

After exhausting other possibilities (re-installing npm and various other nodejs packages), I finally tried the simple one. :-)

sudo yum install nodejs-inherits*

That worked for me.

I had this issue on Windows recently, updating npm fixed it for me.

npm update npm -g

It happend when I switch my node to version 5.5.0 by 'n'.

then I switch back to node 0.10.22,which I used befor, and run

npm update npm -g

then it is fine now

I faced the same error in Windows 7 32 bit system and fixed it by uninstalling the nodejs itself. After freshly installing the nodejs, I ran the following commands

npm install -g npm-windows-upgrade
npm-windows-upgrade -p -v latest

This has fixed the issue for me

Phuc Thai

Running npm install –y helps me in my situation.
I don't know what -y option means.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!