简体   繁体   English

如何解决错误信息“找不到模块'缩写'

[英]How to solve error message "Cannot find module 'abbrev'

My question is very similar to How do I resolve "Cannot find module" error using Node.js? 我的问题非常类似于如何使用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: 我尝试运行UNCSS grunt插件,但是当我尝试安装它时( npm install grunt-uncss --save-dev ),我收到以下错误:

$ 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 :( 根据上面提到的答案,我尝试在项目文件夹和全局中安装这个'abbrev'模块,但这会产生完全相同的错误:(

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? 子问题:1)我想知道,这是一个RUBY错误还是NODE.JS错误? I noticed 'abbrev' is also a Ruby command...? 我注意到'abbrev'也是一个Ruby命令......? 2) Or, could this problem have arisen because I tried to solve the bus error: 10 ? 2)或者,这个问题是否已经出现,因为我试图解决总线错误:10 ( http://shoogledesigns.com/blog/blog/2014/01/13/gruntjs-running-watch-task-waiting-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! 我是一名前端开发人员,但远非命令行大师!

对我来说,它已经通过更新npm本身来解决:

 sudo npm install -g npm

Solution: re-installing node.js, as I mention in my last comment. 解决方案:重新安装node.js,正如我在上一篇评论中提到的那样。

Tell-tale was the very same error-message every time I ran NPM. 每次运行NPM时,Tell-tale都是相同的错误消息。

Removing node-modules and then reinstalling the modules specified in my package.json worked for me. 删除node-modules ,然后重新安装我的package.json指定的模块为我工作。

I did that by runnning the following commands: 我通过运行以下命令来做到这一点:

rm -rf node-modules
npm install

其他两个答案中的任何一个都没有为我解决,但两者都在一起。

I had a very similar issue. 我有一个非常相似的问题。 Removing the entire node_modules folder and re-installing it's worked for me. 删除整个node_modules文件夹并重新安装它对我node_modules I did that by running the following commands: 我通过运行以下命令来做到这一点:

rm -rf node_modules
npm install

Windows user here. Windows用户在这里。 I tried re-installing Node.js (using installer) and it did not help. 我尝试重新安装Node.js(使用安装程序),它没有帮助。 I had to run the rm -rf node_modules to remove the "node_modules" folder at the location listed in the error (midway down). 我必须运行rm -rf node_modules来删除错误中列出的位置的“node_modules”文件夹(中间向下)。

In the OP example it was at Object. 在OP示例中,它位于Object。 ( /usr/local/Cellar/node/0.10.20/lib/node_modules/ /usr/local/Cellar/node/0.10.20/lib/node_modules/

It was something like C:\\Users\\nick\\AppData\\Roaming\\npm\\node_modules 它类似于C:\\ Users \\ nick \\ AppData \\ Roaming \\ npm \\ node_modules

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM