我正在尝试使用grunt运行我的第一个项目。当我尝试在命令行中运行grunt时,我被困在这一点上,我得到一个错误/警告,如下所示:
Traviss-MacBook-Pro-2:GRUNT Travis$ grunt compass
>> Local Npm module "grunt-contrib-jshint" not found. Is it installed?
>> Local Npm module "grunt-contrib-qunit" not found. Is it installed?
Warning: Task "compass" not found. Use --force to continue.
Aborted due to warnings.我安装了jshint和qunit,所以我不知道下一步该怎么解决这个问题。任何帮助都将不胜感激,谢谢。
这是我的grunt.js文件
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
concat: {
options: {
separator: ';'
},
dist: {
src: ['src/**/*.js'],
dest: 'dist/<%= pkg.name %>.js'
}
},
uglify: {
options: {
banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n'
},
dist: {
files: {
'dist/<%= pkg.name %>.min.js': ['<%= concat.dist.dest %>']
}
}
},
qunit: {
files: ['test/**/*.html']
},
jshint: {
files: ['Gruntfile.js', 'src/**/*.js', 'test/**/*.js'],
options: {
// options here to override JSHint defaults
globals: {
jQuery: true,
console: true,
module: true,
document: true
}
}
},
watch: {
files: ['<%= jshint.files %>'],
tasks: ['jshint', 'qunit']
}
});
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-qunit');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.registerTask('test', ['jshint', 'qunit']);
grunt.registerTask('default', ['jshint', 'qunit', 'concat', 'uglify']);
};发布于 2014-10-21 06:27:35
您可能没有在grunt任务表单中使用qunit和jshint的‘grunt contrib’模块。您应该能够使用npm ls | grep contrib之类的工具进行检查。
我建议,在你的项目中,运行:
npm install grunt-contrib-jshint --save-dev和
npm install grunt-contrib-qunit --save-dev 我本以为其他一些grunt.loadNpmTasks()-specified模块也会卡住,所以我有点惊讶没有发生更多的错误。
至于“警告:任务”指南针“找不到”,在gruntfile中没有“指南针”目标(就像qunit、watch等),所以这是有意义的。您可能希望添加一个“['jshint', 'qunit', 'concat', 'uglify']”任务来执行该名称下的任务,或者在命令行上指定另一个目标来执行grunt (或者省略任何特定的目标来执行默认的compass任务)。
https://stackoverflow.com/questions/26471163
复制相似问题