Grunt: jit-grunt: Plugin for the “protractor” task not found

谁说我不能喝 提交于 2019-12-06 13:17:21

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.

The accepted answer follows an anti-pattern and defeats the purpose of the JIT (Just In Time) plugin loader for Grunt.

The goal of jit-grunt is to automatically load the required plugins and thus makes the use of grunt.loadNpmTasks obsolete.

The documentation for jit-grunt explains how the plugin loader is looking for the plugins:

Will automatically search for the plugin from the task name. Search in the following order:

  1. node_modules/grunt-contrib-task-name
  2. node_modules/grunt-task-name
  3. node_modules/task-name

Since you have a task protractor, the plugin loader will try to find a corresponding plugin in this order:

  1. grunt-contrib-protractor
    • doesn't exist in packages.json
  2. grunt-protractor
    • doesn't exist in packages.json
  3. protractor
    • found in packages.json!
    • unfortunately there is a mismatch
    • the required plugin for the task protractor is grunt-protractor-runner

In this case we can set the static mapping, as the error message points out. We do this in the format taskname: grunt_plugin_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'
});

This is an old question, but I hope my answer can help other people who encounter this problem.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!