node.js npm install 缺少模块
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24652681/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
npm install is missing modules
提问by Jeanluca Scaljeri
Before I can run gulpin my project I need to run npm install. This works except on my computer, because I get the following error:
在我可以gulp在我的项目中运行之前,我需要运行npm install. 这在我的计算机上除外,因为我收到以下错误:
Error: Cannot find module 'socket.io'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
...
I can fix this with
我可以解决这个问题
$> npm install socket.io
Now when I do the install command again I get
现在,当我再次执行安装命令时,我得到
Error: Cannot find module 'di'
...
When I install diand run the install command again I get:
当我di再次安装并运行安装命令时,我得到:
Error: Cannot find module 'log4js'
I think that this might continue for a very long time. Any suggestions what is going on here and how to fix this ?
我认为这可能会持续很长时间。任何建议这里发生了什么以及如何解决这个问题?
回答by Rafael Rocha
I've faced the same problem when bootstrapping a MEAN application and add each missing dependencie with npm install packageName --savewas not an option so I came across to npm-install-missingwhom has saved my life :)
在引导 MEAN 应用程序并添加每个缺少的依赖项时,我遇到了同样的问题,npm install packageName --save这不是一个选项,所以我遇到了npm-install-missing,他救了我一命:)
Installation
安装
npm install -g npm-install-missing
npm install -g npm-install-missing
Usage
用法
npm-install-missing
回答by jgillich
Running npm installwill install all dependencies that are specified in the package.json. Seems like you have quite a few dependencies that are not defined that way. Use npm install packageName --saveand npm will add the package to your package.json.
运行npm install将安装在package.json. 似乎您有很多未以这种方式定义的依赖项。使用npm install packageName --save和 npm 会将包添加到您的package.json.
回答by benek
I am using the same version of npm/node. Sometimes, it is like npm is "lost". What I suggest is :
我正在使用相同版本的 npm/node。有时,这就像 npm “丢失”了一样。我的建议是:
- rm of your node modules (at least the one that is concerned)
- npm cache clean
- run "npm install" several times, until all dependencies are resolved and no message are displayed
- rm 节点模块(至少是相关模块)
- npm 缓存清理
- 多次运行“npm install”,直到解决所有依赖项并且不显示任何消息
回答by Seif Tamallah
It seems that gulp need 'karma' dependencies (socket.io ,di ,log4js...) so you will have to run :
似乎 gulp 需要 'karma' 依赖项(socket.io ,di ,log4js...)所以你必须运行:
npm install karma
npm install karma
so just runing this command solved the problem, and all should be good, the same thing happens with grunt as well for some reasons.
所以只要运行这个命令就解决了这个问题,一切都应该很好,同样的事情也发生在 grunt 上,出于某些原因。
回答by Mukeli
To resolve missing npm modules run:
要解决缺少的 npm 模块,请运行:
sudo npm install -g npm-install-missing

