我想用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']);
};
您可能想要發佈Gruntfile.js以獲得更多的上下文。另外,當你說你已經安裝了jshint和qunit時,如果你可以提供用於安裝它們的命令,那也可能有幫助(我是新來的,但我相信你需要使用,例如, 'npm install grunt-contrib-jshint --save-dev'與'npm install jshint --save-dev')。 – 2014-10-20 21:30:57
我用這行安裝qunit sudo npm install qunit-cli並用這行安裝jslint sudo npm install jshint – 2014-10-20 21:56:57
做@BrianHenry說的。並放下'sudo'。這可能不是你想要做的。 (雖然如果你習慣於apt-get,這是很自然的事情 – carbontax 2014-10-22 02:38:57