8

My question is very similar to How do I resolve "Cannot find module" error using Node.js? but I cannot solve my problem using the information provided in the answer given.

I try to run the UNCSS grunt plugin, but when I try to install it (npm install grunt-uncss --save-dev), I get the following error:

$ npm install grunt-uncss --save-dev

module.js:340
    throw err;
          ^
Error: Cannot find module 'abbrev'
    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/local/Cellar/node/0.10.20/lib/node_modules/npm/node_modules/nopt/lib/nopt.js:10:14)
    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)

Based on the answer mentioned above, I tried installing this 'abbrev' module, both in project folder, and globally, but this yields the exact same error :(

npm install -g abbrev

module.js:340
    throw err;
          ^
Error: Cannot find module 'abbrev'
    at Function.Module._resolveFilename (modu
   (ETCETERA)

Main question: How to I solve this error?

Sub questions: 1) I wonder, is this a RUBY error or a NODE.JS error? I noticed 'abbrev' is also a Ruby command...? 2) Or, could this problem have arisen because I tried to solve the bus error: 10 ? (http://shoogledesigns.com/blog/blog/2014/01/13/gruntjs-running-watch-task-waiting-bus-error-10/)

I hope this question doesn't sound too obvious. I'm a front-end developer, but far from a command-line guru!

Community
  • 1
  • 1
Ideogram
  • 1,265
  • 12
  • 21

6 Answers6

3

For me it has been solved by updating npm itself:

 sudo npm install -g npm
david
  • 2,529
  • 1
  • 34
  • 50
1

Solution: re-installing node.js, as I mention in my last comment.

Tell-tale was the very same error-message every time I ran NPM.

Ideogram
  • 1,265
  • 12
  • 21
1

Removing node_modules and then reinstalling the modules specified in my package.json worked for me.

I did that by runnning the following commands:

rm -rf node_modules
npm install
qff
  • 5,524
  • 3
  • 37
  • 62
0

Neither one of the other two answers solved it for me, but both together did.

Jason Swett
  • 43,526
  • 67
  • 220
  • 351
0

I had a very similar issue. Removing the entire node_modules folder and re-installing it's worked for me. I did that by running the following commands:

rm -rf node_modules
npm install
Faisal
  • 4,591
  • 3
  • 40
  • 49
0

Windows user here. I tried re-installing Node.js (using installer) and it did not help. I had to run the rm -rf node_modules to remove the "node_modules" folder at the location listed in the error (midway down).

In the OP example it was at Object. (/usr/local/Cellar/node/0.10.20/lib/node_modules/

It was something like C:\Users\nick\AppData\Roaming\npm\node_modules

NickStees
  • 449
  • 4
  • 12