Nix
Nix

Reputation: 58542

Grunt - Task "undefined" not found

I'm currently getting the same error for all tasks that I run via grunt.

Initializing
Command-line options: --verbose
Reading "Gruntfile.js" Gruntfile...OK

Registering Gruntfile tasks.
Reading package.json...OK
Parsing package.json...OK
Initializing config...OK
Loading "Gruntfile.js" tasks...OK
+ build,default,nick,server,test

No tasks specified, running default tasks.
Running tasks: default

Running "default" task
Warning: Task "undefined" not found. Use --force to continue.

The last warning happens for any task I run.

Grunfile.js(important stuff):

...
grunt.initConfig({
    jshint: {
        options: {
            jshintrc: '.jshintrc'
        },
        all: [
            'Gruntfile.js',
            '<%= yeoman.app %>/scripts/{,*/}*.js',
            '!<%= yeoman.app %>/scripts/libs/{,*/}*.js'
        ]
    },
    ...
});
...
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.registerTask('nick', [ ]);

grunt.registerTask('default', [
    'jshint'
]);

running jshint by itself works fine..

grunt jshint 
>Running "jshint:all" (jshint) task
>> 52 files lint free.
>>
>>Done, without errors.

Done, without errors.

Any help? Let me know if there is any other info you need to help.

Nick.

Upvotes: 2

Views: 2157

Answers (2)

trial-in-error
trial-in-error

Reputation: 23

Another potential cause of this problem is having double commas in a Gruntfile.js's registerTask section. For instance:

grunt.registerTask('dist', ['clean',, 'uglify:dist']);

Note that this will also produce the same error:

grunt.registerTask('dist', ['clean', /*unnecessarytask */, 'uglify:dist']);

Upvotes: 2

jsmiff
jsmiff

Reputation: 96

I had the same issue and all I needed to do was update grunt with:

npm --global update grunt-cli

Upvotes: 1

Related Questions