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,150
- 4
- 12
- 27
9 Answers
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.

- 343
- 2
- 6
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.

- 2,868
- 1
- 25
- 45
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

- 51
- 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.

- 1,150
- 4
- 12
- 27
-
this is what i got from that command on CentOS: `Package nodejs-inherits-2.0.0-4.el6.noarch is obsoleted by nodejs-0.10.40-1.shmz65.1.6.x86_64 which is already installed` – nyxee Sep 26 '15 at 02:14
I had this issue on Windows recently, updating npm fixed it for me.
npm update npm -g

- 35,571
- 4
- 52
- 61
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

- 11
- 3
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

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

- 2,237
- 27
- 30
- 38

- 718
- 7
- 17