Daniel Clifford Daniel Clifford - 4 months ago 26
Javascript Question

Task "jshint" not found

I have only just started to learn how to program using Steven Foote's book 'Learning to program' and I have hit a wall and I am looking for some help please.

When I run; grunt jshint I get the following;

Daniels-Air:projects danielclifford$ sudo grunt jshint
Loading "Gruntfile.js" tasks...ERROR
>> SyntaxError: Unexpected token {
Warning: Task "jshint" not found. Use --force to continue.


my gruntfile.js looks as follows;

module.exports = funtion (grunt) {
grunt.initConfig({
concat: {
release: {
src: ['js/values.js', 'js/prompt.js'],
dest: 'release/main.js'
}
},
copy: {
release: {
src: 'manifest.json',
dest: 'release/manifest.json'
}
},
jshint: {
files: ['js/vales.js', 'js/prompt.js']
}
});
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.registerTask('default', ['jshint', 'concat', 'copy']);
};


I've probably just made a stupid mistake but I can't find it and the other two posts with similar issues haven't helped me either so any help someone can give me would be appreciated.

Thanks!

Answer

Line 1 of the Gruntfile.js should be module.exports = function(grunt) { rather than module.exports = funtion(grunt) {

Not seeing the function declaration can throw the Syntax Error: Unexpected token line that you are receiving when you try and run the task.