Javascript 找不到业力插件依赖项
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32425580/
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
karma plugin dependencies not being found
提问by Matt Westlake
When I run karma start
I get the following issues
当我运行时,karma start
我遇到以下问题
C:\devl\JS\myProject>karma start
06 09 2015 11:30:19.133:WARN [plugin]: Cannot find plugin "karma-chrome-launcher
".
Did you forget to install it ?
npm install karma-chrome-launcher --save-dev
06 09 2015 11:30:19.149:WARN [plugin]: Cannot find plugin "karma-firefox-launche
r".
Did you forget to install it ?
npm install karma-firefox-launcher --save-dev
06 09 2015 11:30:19.159:WARN [plugin]: Cannot find plugin "karma-ie-launcher".
Did you forget to install it ?
npm install karma-ie-launcher --save-dev
when I do npm list
I can see the dependencies at the bottom of the tree
当我这样做时,npm list
我可以看到树底部的依赖项
├─┬ [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ └─┬ [email protected]
│ └─┬ [email protected]
│ └── [email protected]
├── [email protected]
├─┬ [email protected]
│ └── [email protected]
└── [email protected]
I have tried nuking my node_dependencies and running npm install
again and i'm not sure what else to try
我试过取消我的 node_dependencies 并npm install
再次运行,但我不知道还能尝试什么
EDIT: I have verified in my node_dependencies directory and the plugin directories are in there.
编辑:我已经在我的 node_dependencies 目录中进行了验证,并且插件目录在那里。
回答by Joe Liversedge
There are a two seemingly-similar complaints when first getting started with Karma:
刚开始使用Karma时,有两个看似相似的抱怨:
[preprocess]: Can not load "webpack", it is not registered!
Perhaps you are missing some plugin?
and
和
[plugin]: Cannot find plugin "karma-webpack".
Did you forget to install it ?
npm install karma-webpack --save-dev
The following is my best recommendation for fixing these two problems with your configuration…
以下是我用您的配置解决这两个问题的最佳建议......
"Can not load "XYZ", it is not registered!" (sic)
“无法加载“XYZ”,它没有注册!” (原文如此)
The typical solution to the 'Perhaps you are missing some plugin?' message is to make sure it's included within the plugins
array in karma.conf.js
.
“也许您缺少一些插件?”的典型解决方案。消息是确保它包含plugins
在karma.conf.js
.
plugins: [
'karma-chrome-launcher',
'karma-tap',
'karma-sourcemap-loader',
'karma-webpack' // *** This 'registers' the Karma webpack plugin.
],
"Cannot find plugin 'karma-xyz'."
“找不到插件‘karma-xyz’。”
If you've already installed it by running npm install karma-xyz --save-dev
, but Karma still prompts (read: taunts) you with the "Did you forget to install it ?" warning, you may have a global installation of the Karma module.
如果您已经通过运行安装了它npm install karma-xyz --save-dev
,但 Karma 仍然会提示您(阅读:嘲讽)“您忘记安装它了吗?” 警告,您可能有 Karma 模块的全局安装。
Chances are that when you installed a global copy of the karma-cli
using -g
, you included karma
(or were told to do so by a well-meaning tutorial), but that can cause problems resolving modules in certain versions (i.e., every version I've ever used). Karma's installation documentationrecommends that the module should be a local installation using npm install karma --save-dev
.
有可能,当您安装karma-cli
using的全局副本时-g
,您包含了karma
(或被善意的教程告知这样做),但这可能会导致在某些版本(即,我曾经使用过的每个版本)中解析模块时出现问题)。Karma 的安装文档建议模块应该是使用npm install karma --save-dev
.
If you have a global Karma installation, try something like:
如果您有全局 Karma 安装,请尝试以下操作:
$ npm uninstall -g karma
$ npm install karma --save-dev
回答by valdeci
I think that you installed these plugins globally.
我认为您全局安装了这些插件。
I had the same problem and I solved by installing the chrome-karma-launcher using the linkflag:
我遇到了同样的问题,我通过使用链接标志安装 chrome-karma-launcher 解决了:
npm install karma-chrome-launcher --save-dev --link
Do this with all browsers' plugins
使用所有浏览器的插件执行此操作
npm install karma-firefox-launcher --save-dev --link
npm install karma-ie-launcher --save-dev --link
I don't know if this is the best approach, but this solved for me.
我不知道这是否是最好的方法,但这对我来说解决了。
回答by akhurad
My answer might be a very rookie one, but did you add those plugins in the plugins array in the karma config file?
我的答案可能是一个非常菜鸟的答案,但是您是否在 karma 配置文件的 plugins 数组中添加了这些插件?
For example:
例如:
plugins: [
'karma-jasmine-html-reporter',
'karma-spec-reporter',
'karma-chrome-launcher',
'karma-jasmine',
'karma-coverage',
'karma-phantomjs-launcher'
],
Mine got resolved after I added the plugins to this array.
在我将插件添加到这个数组后,我的问题得到了解决。
回答by Massi Issar
I had the same problem, but i fixed by this command :
我有同样的问题,但我用这个命令修复了:
npm install -g karma-cli
回答by hashcoder
Just to add if someone come acrosss!!
只是在有人遇到时补充!!
I was getting an annoying issue, "Cannot load browser "Chrome": it is not registered! Perhaps you are missing some plugin?" when I run 'grunt test'
我遇到了一个烦人的问题,“无法加载浏览器“Chrome”:它没有注册!也许你错过了一些插件?当我运行“咕噜声测试”时
I had added the plugin in plugins[] in karma.conf.js, but still I was getting this error . The issue was I didn't add the plugin into karma:options:plugins array in GruntFile.js.After I added the plugin there, the issue vanished!!
我已经在 karma.conf.js 的 plugins[] 中添加了插件,但仍然出现此错误。问题是我没有将插件添加到 GruntFile.js 中的 karma:options:plugins 数组中。在那里添加插件后,问题就消失了!