0

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

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”,“devDependencies”:{“grunt”:“~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-stylish": "^2.0.1" } }

4

1 回答 1

1

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

npm install grunt-contrib-jshint --save-dev
于 2015-09-19T07:18:33.550 回答