【问题标题】:Can't find module hooker when run grunt jshint运行 grunt jshint 时找不到模块挂钩
【发布时间】:2015-12-14 12:16:10
【问题描述】:

当我在 cmd 中运行 grunt jshint 时,显示以下错误:

Loading "jshint.js" tasks...ERROR
Error: Cannot find module 'hooker
Warning: Task "jshint:myFiles" not found. Use --force to continue.
Aborted due to warnings.`

这是我的代码:

module.exports = function (grunt) {
grunt.initConfig({

// define source files and their destinations
uglify: {
   min: {
        files: grunt.file.expandMapping(['vendors/**/**/*.js','!vendors/**/**/*.min.js'], '', {
            rename: function(destBase, destPath) {
                return destBase+destPath.replace('.js', '.min.js');
            }
        })
    }
},
watch: {
    files:['vendors/**/**/*.min.js'],
    tasks: ['default']
},
clean: ["vendors"],
bower: {
    install: {
       //just run 'grunt bower:install' and you'll see files from your Bower packages in lib directory 
    }
},
jshint: {
  // You get to make the name
  // The paths tell JSHint which files to validate
  myFiles: ['gruntfile.js']
},
cssmin:{
    target: {
        files: grunt.file.expandMapping(['vendors/**/**/*.css','!vendors/**/**/*.min.css'], '', {
            rename: function(destBase, destPath) {
                return destBase+destPath.replace('.css', '.min.css','');
            }
        })
    }
},
});

grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-bower-installer');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-watch-github');

// register at least this one task
grunt.registerTask('default', [ 'jshint','uglify','cssmin' ]);


};

我安装了这些插件:

{ “名称”:“我的项目名称”, “版本”:“1.0.0”, “开发依赖”:{ “咕噜”:“〜0.4.2”, "grunt-bower-installer": "^0.3.6", "grunt-contrib-clean": "^0.6.0", "grunt-contrib-compass": "^1.0.3", "grunt-contrib-cssmin": "^0.14.0", "grunt-contrib-imagemin": "^0.9.4", "grunt-contrib-jshint": "^0.11.3", "grunt-contrib-uglify": "~0.2.4", “grunt-contrib-watch”:“~0.5.3”, "grunt-watch-github": "^0.1.1", “jshint 风格”:“^2.0.1” } }

【问题讨论】:

    标签: gruntjs runtime-error grunt-contrib-jshint


    【解决方案1】:

    我再次解决了安装 jshint 模块的问题。因为jshint没有正确安装

    npm install grunt-contrib-jshint --save-dev
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-10-23
      • 1970-01-01
      • 1970-01-01
      • 2014-11-18
      • 2015-03-07
      • 2018-08-04
      • 2015-04-07
      相关资源
      最近更新 更多