Grunt:jit-grunt:“量角器”的插件未找到任务 [英] Grunt: jit-grunt: Plugin for the "protractor" task not found

查看:179
本文介绍了Grunt:jit-grunt:“量角器”的插件未找到任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



  yo angular对于yeoman / grunt / bower我是新手,我正在设置一个angularjs项目: 

我自己对gruntfile做了一些修改,最近我发现量角器非常有用,我想补充一点我的项目。我遵循了许多在线指令(如这一个通过Grunt集成量角器与Yeoman 2年前),但我仍然无法正确安装量角器。



这是我的 Gruntfile.js :(只显示相关部分)

 'use strict'; 
module.exports =函数(grunt){

//时间任务需要多长时间。在优化构建时间时可以提供帮助
require('time-grunt')(grunt);

//自动加载所需的Grunt任务
require('jit-grunt')(grunt,{
useminPrepare:'grunt-usemin',
ngtemplates:' grunt-angular-templates',
cdnify:'grunt-google-cdn'
});

//应用程序的可配置路径
var appConfig = {
app:require('./ bower.json')。appPath || 'app',
dist:'dist'
};

//定义所有任务的配置
grunt.initConfig({

//项目设置
yeoman:appConfig,

...
...

//将Bower组件自动注入应用程序
wiredep:{
app:{
src :['<%= yeoman.app%> /index.html'],
ignorePath:/\.\.\//
},
test:{
devDependencies:true,
src:'<%= karma.unit.configFile%>',
ignorePath:/\.\.\//,
filetypes:{
js:{
block:/(([\s\t] *)\ / {2} \s *?bower:\s *?(\\ \\ s *))(\ n | \r |。)*?(\ / {2} \s * endbower)/ gi,
detect:{
js:/'( 。* \.js)'/ gi
},
替换:{
js:'\'{{filePath}} \','
}
}
$ b $ sa $ {
src:['<%= yeoman.app%> / styles / {,* /} *。{scss, sass}'],
ignorePath:/(\.\.\/){1,2}bower_components\//
}
},

...
...

//测试设置

karma:{
单元:{
configFile:'test /karma.conf.js',
singleRun:true
}
},

量角器:{
选项:{
keepalive: true,
configFile:'protractor.conf.js'
},
run:{}
}

});

grunt.registerTask('serve','编译然后启动一个连接web服务器',函数(target){
if(target ==='dist'){
返回grunt.task.run(['build','connect:dist:keepalive']);
}

grunt.task.run([
'clean:s​​erver ',
'wiredep',
'并发:服务器',
'postcss:服务器',$ b $'connect:livereload',
'watch'
]);
});

grunt.registerTask('test',[
'clean:s​​erver',
'wiredep',
'concurrent'test',
' postcss',
'connect:test',
'karma',
'量角器:运行'
]);
};

这是我的 package.json

  {
name:Website,
private:true,
devDependencies:{
autoprefixer-core:^ 5.2.1,
compass:^ 0.1.1,
grunt:^ 0.4.5 ,
grunt-angular-templates:^ 0.5.7,
grunt-concurrent:^ 1.0.0,
grunt-contrib-clean: ^ 0.6.0,
grunt-contrib-compass:^ 1.0.0,
grunt-contrib-concat:^ 0.5.0,
grunt-contrib-connect:^ 0.9.0,
grunt-contrib-copy:^ 0.7.0,
grunt-contrib-cssmin:^ 0.12.0 ,
grunt-contrib-htmlmin:^ 0.4.0,
grunt-contrib-imagemin:^ 1.0.0,
grunt-contrib-jshint :^ 0.11.0,
grunt-contrib-uglify:^ 0.7.0,
grunt-contrib-watch:^ 0.6.1,
grunt-filerev:^ 2.1.2,
grunt-google-cdn:^ 0.4.3,
grunt-jscs:^ 1.8.0,
grunt-karma:^ 0.12.2,
grunt-new呃:^ 1.1.0,
grunt-ng-annotate:^ 0.9.2,
grunt-postcss:^ 0.5.5,
grunt-protractor-runner:^ 3.0.0,
grunt-svgmin:^ 2.0.0,
grunt-usemin:^ 3.0.0,
grunt-wiredep:^ 2.0.0,
jasmine-core:^ 2.4.1,
jit-grunt:^ 0.9.1,
jshint-stylish:^ 1.0.0,
karma:^ 0.13.22,
karma-jasmine:^ 0.3.8,
karma-phantomjs-launcher:^ 1.0.0,
karma2:^ 0.13.22,
phantomjs-prebuilt:^ 2.1.7,
量角器:^ 3.0.0,
time-grunt:^ 1.0.0
},
engines:{
node:> = 0.10.0
},
scripts:{
test:karma start test / karma.conf.js,
install:node node_modules / protractor / bin / webdriver-manager update
},
dependencies:{}
}

我使用 jit-grunt (现在是默认值),所以它会为我加载这些插件。



我确实安装了量角器 grunt-protractor-runner 按照上面提到的帖子和其他来源,如量角器 grunt-protractor-runner 的官方网站。在我的本地 node_modules 中:

  $ ls node_modules / grep量角器
grunt-protractor-runner
量角器

但是不管我做,我仍然从grunt得到错误:

  $ grunt量角器

jit-grunt:找不到量角器任务的插件。
如果您已经安装了插件,请设置静态映射。
请参阅https://github.com/shootaroo/jit-grunt#static-mappings

警告:任务量角器失败。使用--force继续。

并运行grunt测试:

<$ p $运行clean:s​​erver(clean)任务
>>运行clean:s​​erver(clean)任务
> $ g $ g $ b $清理1个路径。

...
...

运行karma:unit(karma)任务
01 05 2016 15:03:51.048:WARN [观察者]:模式
01 05 2016 15:03:51.094:INFO [karma]:Karma v0.13.22服务器从http:// localhost:8080 /
开始01 05 2016 15:03:51.112 :INFO [启动程序]:启动浏览器PhantomJS
01 05 2016 15:03:52.259:INFO [PhantomJS 2.1.1(Mac OS X 0.0.0)]:使用套接字/#68w8QMUehAm8AAf2AAAA连接到ID 17032121
PhantomJS 2.1.1(Mac OS X 0.0.0):执行2的2 SUCCESS(0.003秒/ 0.026秒)

jit-grunt:找不到量角器任务的插件。
如果您已经安装了插件,请设置静态映射。
请参阅https://github.com/shootaroo/jit-grunt#static-mappings

警告:任务量角器:运行失败。使用--force继续。

由于警告而中止。

有什么我错过了吗?我一直坚持这几天。任何帮助都非常感谢。

解决方案

感谢@theaccordance的建议和提示。原来, JIT-grunt 加载 grunt-protractor-runner 可能有一些困难。

在Gruntfile.js中添加 grunt.loadNpmTasks('grunt-protractor-runner'); 将解决问题。

I am new to yeoman/grunt/bower and I am working on setting up a angularjs project with:

yo angular

I made some changes to gruntfile myself and recently I found protractor very useful and I wanted to add that to my project. I followed a lot of instructions online (like this one Integrating Protractor with Yeoman via Grunt 2 years ago) but I still cannot get protractor properly installed.

Here is my Gruntfile.js: (only showed relevant parts)

'use strict';
module.exports = function (grunt) {

  // Time how long tasks take. Can help when optimizing build times
  require('time-grunt')(grunt);

  // Automatically load required Grunt tasks
  require('jit-grunt')(grunt, {
    useminPrepare: 'grunt-usemin',
    ngtemplates: 'grunt-angular-templates',
    cdnify: 'grunt-google-cdn'
  });

  // Configurable paths for the application
  var appConfig = {
    app: require('./bower.json').appPath || 'app',
    dist: 'dist'
  };

  // Define the configuration for all the tasks
  grunt.initConfig({

    // Project settings
    yeoman: appConfig,

    ...
    ...

    // Automatically inject Bower components into the app
    wiredep: {
      app: {
        src: ['<%= yeoman.app %>/index.html'],
        ignorePath:  /\.\.\//
      },
      test: {
        devDependencies: true,
        src: '<%= karma.unit.configFile %>',
        ignorePath:  /\.\.\//,
        fileTypes:{
          js: {
            block: /(([\s\t]*)\/{2}\s*?bower:\s*?(\S*))(\n|\r|.)*?(\/{2}\s*endbower)/gi,
              detect: {
                js: /'(.*\.js)'/gi
              },
              replace: {
                js: '\'{{filePath}}\','
              }
            }
          }
      },
      sass: {
        src: ['<%= yeoman.app %>/styles/{,*/}*.{scss,sass}'],
        ignorePath: /(\.\.\/){1,2}bower_components\//
      }
    }, 

    ...
    ...

    // Test settings

    karma: {
      unit: {
        configFile: 'test/karma.conf.js',
        singleRun: true
      }
    },

    protractor: {
      options: {
        keepalive: true,
        configFile: 'protractor.conf.js'
      },
      run: {}
    }

  });

  grunt.registerTask('serve', 'Compile then start a connect web server', function (target) {
    if (target === 'dist') {
      return grunt.task.run(['build', 'connect:dist:keepalive']);
    }

    grunt.task.run([
      'clean:server',
      'wiredep',
      'concurrent:server',
      'postcss:server',
      'connect:livereload',
      'watch'
    ]);
  });

  grunt.registerTask('test', [
    'clean:server',
    'wiredep',
    'concurrent:test',
    'postcss',
    'connect:test',
    'karma',
    'protractor:run'
  ]);
};

Here is my package.json:

{
  "name": "Website",
  "private": true,
  "devDependencies": {
    "autoprefixer-core": "^5.2.1",
    "compass": "^0.1.1",
    "grunt": "^0.4.5",
    "grunt-angular-templates": "^0.5.7",
    "grunt-concurrent": "^1.0.0",
    "grunt-contrib-clean": "^0.6.0",
    "grunt-contrib-compass": "^1.0.0",
    "grunt-contrib-concat": "^0.5.0",
    "grunt-contrib-connect": "^0.9.0",
    "grunt-contrib-copy": "^0.7.0",
    "grunt-contrib-cssmin": "^0.12.0",
    "grunt-contrib-htmlmin": "^0.4.0",
    "grunt-contrib-imagemin": "^1.0.0",
    "grunt-contrib-jshint": "^0.11.0",
    "grunt-contrib-uglify": "^0.7.0",
    "grunt-contrib-watch": "^0.6.1",
    "grunt-filerev": "^2.1.2",
    "grunt-google-cdn": "^0.4.3",
    "grunt-jscs": "^1.8.0",
    "grunt-karma": "^0.12.2",
    "grunt-newer": "^1.1.0",
    "grunt-ng-annotate": "^0.9.2",
    "grunt-postcss": "^0.5.5",
    "grunt-protractor-runner": "^3.0.0",
    "grunt-svgmin": "^2.0.0",
    "grunt-usemin": "^3.0.0",
    "grunt-wiredep": "^2.0.0",
    "jasmine-core": "^2.4.1",
    "jit-grunt": "^0.9.1",
    "jshint-stylish": "^1.0.0",
    "karma": "^0.13.22",
    "karma-jasmine": "^0.3.8",
    "karma-phantomjs-launcher": "^1.0.0",
    "karma2": "^0.13.22",
    "phantomjs-prebuilt": "^2.1.7",
    "protractor": "^3.0.0",
    "time-grunt": "^1.0.0"
  },
  "engines": {
    "node": ">=0.10.0"
  },
  "scripts": {
    "test": "karma start test/karma.conf.js",
    "install": "node node_modules/protractor/bin/webdriver-manager update"
  },
  "dependencies": {}
}

I used jit-grunt ( as default now ) so it will load those plugins for me.

I have surely installed protractor and grunt-protractor-runner following the post I mentioned above and other sources like official website of protractor and grunt-protractor-runner. In my local node_modules:

$ ls node_modules/ | grep protractor
grunt-protractor-runner
protractor

But no matter what I do, I am still getting the error from 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.

And running grunt test:

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

Is there something I missed? I have been stuck with this for days. Any help is much appreciated.

解决方案

Thanks for the suggestion and hint from @theaccordance. Turns out that JIT-grunt probably has some difficulty loading grunt-protractor-runner.

Adding grunt.loadNpmTasks('grunt-protractor-runner'); in Gruntfile.js will resolve the problem.

这篇关于Grunt:jit-grunt:“量角器”的插件未找到任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆