9

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!

6
  • What is your question? Is it a ruby error on node.js? Or, how to solve that?
    – Vinz243
    Commented Jun 27, 2014 at 8:52
  • I specified the question, thanks. I want to solve the problem, but I'm also curious about the 'why'
    – Ideogram
    Commented Jun 27, 2014 at 9:49
  • please try npm lsin your project and add it.
    – Vinz243
    Commented Jun 27, 2014 at 9:54
  • Thanks,... it yields the same error as mentioned above! Ergo,... npm is broke...?
    – Ideogram
    Commented Jun 27, 2014 at 9:59
  • Have you tried npm cache clear?
    – Vinz243
    Commented Jun 27, 2014 at 10:01

6 Answers 6

3

For me it has been solved by updating npm itself:

 sudo npm install -g npm
1
  • 1
    I was skeptical, but yes, this fixed my problem. At least try it out before anything else!
    – Ethan Mick
    Commented Jul 8, 2017 at 22:06
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.

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
1
  • 1
    It should be "rm -rf node_modules"
    – maruf571
    Commented Sep 7, 2021 at 9:12
0

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

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.