异常:jshint-junit-reporter

Exception with :jshint-junit-reporter

我用 Grunt 写了一个 jshint 的 demo,代码如下:

module.exports = function(grunt) {
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('jshint-junit-reporter');
    grunt.initConfig({
        jshint: {
            all: ['Gruntfile.js'],
            reporter: require("jshint-junit-reporter"),
            reporterOutput: "junit-output.xml"
        }
    });
};

出现异常:

这是 jshint-junit-reporter 安装的结果:

及相关软件版本: npm:3.10.8 grunt-cli v1.2.0 咕噜 v1.0.1 nodeJS:v0.12.7 我非常感谢任何建议

reporter: 和 reporterOutput: 都是选项,应该在选项块中指定。尝试将您的任务更新为:

jshint: {
    all: ['Gruntfile.js'],
    options: {
        reporter: require("jshint-junit-reporter"),
        reporterOutput: "junit-output.xml"
    }
}

https://github.com/gruntjs/grunt-contrib-jshint