Reputation: 1
Im getting this error when trying to execute grunt
$ grunt
Loading "Gruntfile.js" tasks...ERROR
>> SyntaxError: Unexpected token :
Warning: Task "default" not found. Use --force to continue.
Aborted due to warnings.
My gruntfile is as follows:
module.exports = function(grunt) {
grunt.initConfig({
cssmin: {
target: {
files: {[
expand: true,
cwd: '/css',
src: [ '*.css', '!*min.css.' ],
ext: '.min.css'
]}
}
}
watch: {
sass: {
files: ['sass/*.sass'],
tasks: ['sass'],
},
},
});
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.registerTask('default', ['watch']);
};
All of my dependencies are properly installed and inside the package.json. I've stripped everything down to just this test file, I would normally have more tasks. I've rewritten it in coffeescript to no avail. Passing any value for grunt.registerTask()
throws and error for the named value, rather than default.
Any ideas?
Upvotes: 0
Views: 169
Reputation: 3712
You had a couple of syntax errors. One was that you were missing a comma before the "watch" and the other one was the "files" array in the "cssmin" task.
This should work:
module.exports = function(grunt) {
grunt.initConfig({
cssmin: {
target: {
files: [{
expand: true,
cwd: '/css',
src: [ '*.css', '!*min.css.' ],
ext: '.min.css'
}]
}
},
watch: {
sass: {
files: ['sass/*.sass'],
tasks: ['sass'],
},
},
});
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.registerTask('default', ['watch']);
};
Upvotes: 1