9
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)
hourback
  • 1,150
  • 4
  • 12
  • 27

9 Answers9

8

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.

user1978317
  • 343
  • 2
  • 6
6

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
Nithin
  • 3,679
  • 3
  • 30
  • 55
Nico
  • 4,248
  • 1
  • 20
  • 19
5

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.

Mohamed Yakout
  • 2,868
  • 1
  • 25
  • 45
3

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
0

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.

hourback
  • 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
0

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

npm update npm -g
SavoryBytes
  • 35,571
  • 4
  • 52
  • 61
0

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

liuyuekeng
  • 11
  • 3
0

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

Nigilan
  • 766
  • 1
  • 6
  • 20
-3

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

Nathan Tuggy
  • 2,237
  • 27
  • 30
  • 38
Phuc Thai
  • 718
  • 7
  • 17