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

佐手、 提交于 2019-12-22 04:19:10

问题


module.js:340
throw err;
      ^
Error: Cannot find module 'inherits'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/usr/lib/node_modules/npmconf/npmconf.js:3:16)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)

回答1:


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.




回答2:


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



回答3:


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.




回答4:


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



回答5:


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.




回答6:


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

npm update npm -g



回答7:


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




回答8:


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




回答9:


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



来源:https://stackoverflow.com/questions/19933077/running-npm-returns-error-cannot-find-module-inherits

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