Recursive process.nextTick detected – Issue with Grunt and Watch

Recently came up against this issue when using Watch with Grunt. I’m running Grunt 0.4.5 and Watch 0.6.1. When I would run “grunt watch” I would get the following error: “Recursive process.nextTick detected.” The issue was that I had registered a “watch” task as well as loaded the “watch” task. For example:

module.exports = function(grunt) {

    grunt.initConfig({
        watch: {
            files: ['app/**/*.js'],
            tasks: ['jasmine'],
            options: {
                spawn: false
            }
        },
    });

    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.registerTask('watch', ['watch']);

To get rid of the issue, just remove the registerTask call like so:

module.exports = function(grunt) {

    grunt.initConfig({
        watch: {
            files: ['app/**/*.js'],
            tasks: ['jasmine'],
            options: {
                spawn: false
            }
        },
    });

    grunt.loadNpmTasks('grunt-contrib-watch');

It was a careless mistake on my part as you are able to create your own tasks in Grunt which in turn perform other tasks.

Don Marges

Don Marges

Fullstack Web Developer

comments powered by Disqus
rss facebook twitter github youtube mail spotify instagram linkedin