【问题标题】:grunt-contrib-jshint not show messagegrunt-contrib-jshint 不显示消息
【发布时间】:2017-09-13 15:17:25
【问题描述】:

我已经创建了一个新节点项目,我已经安装了很多模块并创建了第一个 index.js 文件

package.json

{
  "name": "parser-test",
  "version": "1.0.0",
  "description": "parser test",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "luca bottoni",
  "license": "ISC",
  "dependencies": {
    "node-cmd": "^3.0.0"
  },
  "devDependencies": {
    "grunt": "^1.0.1",
    "grunt-contrib-jshint": "^1.1.0",
    "grunt-contrib-watch": "^1.0.0",
    "grunt-exec": "^3.0.0"
  }
}

index.js(失败了,因为我想查看 jshint 消息!)

console.log("test");
a={a=6};

如果我从项目文件夹中发送 cmd jshint index.js 我会看到(工作正常):

index.js: line 3, col 5, Expected ':' and instead saw '='.
1 error

现在我想使用 grunt 任务来检查我的文件

Gruntfile.js

module.exports = function(grunt) {
    // Project configuration.
    grunt.initConfig({
                     pkg:  grunt.file.readJSON('package.json'),
                     watch:{
                         scripts:{
                             files:["./*.js"],
                             tasks:['jshint']
                         }
                     },
                     jshint: {
                         files: ['Gruntfile.js',"index.js"]
                     }
                 });
// Load the plugin that provides the "uglify" task.
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-jshint');
// Default task(s).
grunt.registerTask('default', ['watch:scripts']);
grunt.registerTask('jshint', ['jshint']);
};

现在我尝试将单任务 jshint 与命令 grunt jshint 一起使用,但没有看到任何消息。如果我使用手表,则仅在第一次观看任务后不检查文件 index.js 的任何更改。

我不明白为什么直接命令 jshint 工作,但任务 grunt 保持冻结

【问题讨论】:

    标签: grunt-contrib-jshint


    【解决方案1】:

    经过多次测试,我已经解决了

    我有关于 grunt 命令的详细信息

    grunt jshint --verbose 我看到了无限:

    运行“jshint”任务

    运行“jshint”任务

    运行“jshint”任务

    运行“jshint”任务

    运行“jshint”任务

    运行“jshint”任务

    注册任务和定义中的任务同名“jshint”,我在grunt.registerTask('jshints', ['jshint'])中修改了名称;

    现在工作正常

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-25
      • 1970-01-01
      • 2015-01-25
      • 2017-06-12
      相关资源
      最近更新 更多