Javascript Grunt:jit Grunt:Plugin for";量角器“;找不到任务
我是yeoman/grunt/bower的新员工,我正在与以下人员建立angularjs项目:Javascript Grunt:jit Grunt:Plugin for";量角器“;找不到任务,javascript,protractor,gruntjs,yeoman,Javascript,Protractor,Gruntjs,Yeoman,我是yeoman/grunt/bower的新员工,我正在与以下人员建立angularjs项目: yo angular 我自己对gruntfile做了一些修改,最近我发现量角器非常有用,我想把它添加到我的项目中。我在网上遵循了很多说明(比如两年前的这个),但我仍然无法正确安装量角器 这是我的grunfile.js:(仅显示相关部分) 我使用了jit-grunt(现在是默认值),因此它将为我加载这些插件 我肯定已经安装了量角器和格朗特量角器转轮,遵循我上面提到的帖子和其他来源,如量角器和格朗特量角
yo angular
我自己对gruntfile做了一些修改,最近我发现量角器非常有用,我想把它添加到我的项目中。我在网上遵循了很多说明(比如两年前的这个),但我仍然无法正确安装量角器
这是我的grunfile.js
:(仅显示相关部分)
我使用了jit-grunt
(现在是默认值),因此它将为我加载这些插件
我肯定已经安装了量角器
和格朗特量角器转轮
,遵循我上面提到的帖子和其他来源,如量角器
和格朗特量角器转轮
的官方网站。在我的本地节点\u模块中
:
$ ls node_modules/ | grep protractor
grunt-protractor-runner
protractor
但无论我做什么,我还是从grunt那里得到了错误:
$ grunt protractor
jit-grunt: Plugin for the "protractor" task not found.
If you have installed the plugin already, please setting the static mapping.
See https://github.com/shootaroo/jit-grunt#static-mappings
Warning: Task "protractor" failed. Use --force to continue.
并运行grunt测试:
$ grunt test
Running "clean:server" (clean) task
>> 1 path cleaned.
...
...
Running "karma:unit" (karma) task
01 05 2016 15:03:51.048:WARN [watcher]: Pattern
01 05 2016 15:03:51.094:INFO [karma]: Karma v0.13.22 server started at http://localhost:8080/
01 05 2016 15:03:51.112:INFO [launcher]: Starting browser PhantomJS
01 05 2016 15:03:52.259:INFO [PhantomJS 2.1.1 (Mac OS X 0.0.0)]: Connected on socket /#68w8QMUehAm8AAf2AAAA with id 17032121
PhantomJS 2.1.1 (Mac OS X 0.0.0): Executed 2 of 2 SUCCESS (0.003 secs / 0.026 secs)
jit-grunt: Plugin for the "protractor" task not found.
If you have installed the plugin already, please setting the static mapping.
See https://github.com/shootaroo/jit-grunt#static-mappings
Warning: Task "protractor:run" failed. Use --force to continue.
Aborted due to warnings.
我错过了什么吗?这件事我已经坚持了好几天了。非常感谢您的帮助。感谢@theaccordance的建议和提示。事实证明,
JIT-grunt
加载grunt量角器运行程序可能有一些困难
添加grunt.loadNpmTasks('grunt-gragrator-runner')将解决此问题 被接受的答案遵循了一种反模式,并且违背了Grunt的JIT(即时)插件加载程序的目的
jit-grunt
的目标是自动加载所需的插件,从而使grunt.loadNpmTasks
的使用过时
forjit grunt
解释了插件加载程序是如何查找插件的:
将自动从任务名称中搜索插件。搜索
顺序如下:
节点\模块/grunt contrib任务名称
节点\单元模块/grunt任务名称
节点\单元模块/任务名称
由于您有一个任务量角器
,插件加载程序将尝试按以下顺序查找相应的插件:
grunt-contrib量角器
- 在
packages.json中不存在
grunt量角器
- 在
packages.json中不存在
量角器
- 可在
packages.json中找到李>
- 不幸的是,存在不匹配
- 任务
量角器
所需的插件是grunt量角器运行程序
在这种情况下,我们可以设置静态映射,正如错误消息所指出的那样。我们以taskname
:grunt\u plugin\u name
的格式执行此操作:
// Automatically load required Grunt tasks
require('jit-grunt')(grunt, {
useminPrepare: 'grunt-usemin',
ngtemplates: 'grunt-angular-templates',
cdnify: 'grunt-google-cdn',
protractor: 'grunt-protractor-runner'
});
//自动加载所需的Grunt任务
要求(“jit-grunt”)(grunt{
useminPrepare:'grunt usemin',
ngtemplates:“grunt角度模板”,
cdnify:“咕噜咕噜谷歌cdn”,
量角器:“咕噜咕噜的量角器跑步者”
});代码>
这是一个老问题,但我希望我的回答能帮助其他遇到此问题的人。如果您删除了JIT-grunt
,它是否正常运行?谢谢@theaccordance的回复!禁用JIT grunt后,我尝试加载这些Npm任务。我发现我需要手动加载“grunt量角器”。现在量角器似乎工作正常了!(至少它是格伦特发现的,谢谢!!
$ grunt test
Running "clean:server" (clean) task
>> 1 path cleaned.
...
...
Running "karma:unit" (karma) task
01 05 2016 15:03:51.048:WARN [watcher]: Pattern
01 05 2016 15:03:51.094:INFO [karma]: Karma v0.13.22 server started at http://localhost:8080/
01 05 2016 15:03:51.112:INFO [launcher]: Starting browser PhantomJS
01 05 2016 15:03:52.259:INFO [PhantomJS 2.1.1 (Mac OS X 0.0.0)]: Connected on socket /#68w8QMUehAm8AAf2AAAA with id 17032121
PhantomJS 2.1.1 (Mac OS X 0.0.0): Executed 2 of 2 SUCCESS (0.003 secs / 0.026 secs)
jit-grunt: Plugin for the "protractor" task not found.
If you have installed the plugin already, please setting the static mapping.
See https://github.com/shootaroo/jit-grunt#static-mappings
Warning: Task "protractor:run" failed. Use --force to continue.
Aborted due to warnings.
// Automatically load required Grunt tasks
require('jit-grunt')(grunt, {
useminPrepare: 'grunt-usemin',
ngtemplates: 'grunt-angular-templates',
cdnify: 'grunt-google-cdn',
protractor: 'grunt-protractor-runner'
});