90

I'm running Lion 10.9.2 with nodejs v0.10.26

I want to setup an automated compilation on sass files and a live reload with grunt, nothing complicated but...

When running grunt watch I get the following error

(node) warning: Recursive process.nextTick detected. This will break in the next version of node. Please use setImmediate for recursive deferral.

util.js:35
  var str = String(f).replace(formatRegExp, function(x) {
                      ^
RangeError: Maximum call stack size exceeded

here is the Gruntfile.js

module.exports = function(grunt) {

    // Project configuration.
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),

        sass: {
            dist: {
                files: {
                    'assets/css/styles.css': 'assets/sass/styles.scss'
                }
            }
        },
        watch: {
            all: {
                files: 'index.html', // Change this if you are not watching index.html
                options: {
                    livereload: true  // Set livereload to trigger a reload upon change
                }
            },
            css: {
                files:  [ 'assets/sass/**/*.scss' ],
                tasks:  [ 'sass' ],
                options: {
                    spawn: false
                }
            },
            options: {
                livereload: true // Set livereload to trigger a reload upon change
            }
        }

    });

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

    grunt.registerTask('watch', [ 'watch']);

    grunt.registerTask('default', [ 'sass', 'watch' ]);

};

and here is the package.json

{
  "name": "application",
  "version": "0.0.1",
  "private": true,
  "devDependencies": {
    "grunt": "~0.4.2",
    "grunt-contrib-watch": "~0.5.3",
    "grunt-contrib-sass": "~0.7.3"
  }
}
An Lee
  • 13
  • 3
denisjacquemin
  • 7,414
  • 10
  • 55
  • 72

6 Answers6

299

I finally figured out a similar problem I was having with SASS. I was using

grunt.registerTask('sass', [ 'sass']);

The trick was that Grunt doesn't seem to like the repetition in names. When I switch to

grunt.registerTask('styles', [ 'sass']);

Everything worked as it should.

Bob Rockefeller
  • 4,492
  • 2
  • 28
  • 35
  • 2
    awesome, thanks for spotting this. I realised we don't need to register a single task anyway, because grunt will run 'grunt sass' when you type that into the command line. – stefan Apr 01 '14 at 06:23
  • 1
    Thank you for answering this... I've been bashing my head on the desk for the last hour and a half figuring out why the `grunt-bower-concat` plugin was giving me that output. – Derek Jul 09 '14 at 02:54
  • Oddly worked for me fine with sass, but broke on watch, thanks – Ryan Knell Mar 02 '15 at 03:55
17

Just had this problem. Resolved it by removing grunt.registerTask('watch', [ 'watch']);

11

I just fixed a similar error "Recursive process.nextTick detected" causing by command: grunt server

The solution? Use sudo grunt serve instead

krazyweb
  • 141
  • 3
  • this should never be the solution. `sudo` shouldn't be used unless its something that is actually changing your system. It sounds like you did `sudo npm install` which is often bad – Eddie Monge Jr Jan 13 '15 at 19:34
1

you could try this one, it fixed the issue for me, working with Yeoman 1.3.3 and Ubuntu 14.04 Grunt watch error - Waiting...Fatal error: watch ENOSPC

Community
  • 1
  • 1
hybrisCole
  • 74
  • 5
1

I was getting error in even trying to install grunt. Running npm dedupe solved my problem as answered here: Grunt watch error - Waiting...Fatal error: watch ENOSPC

Community
  • 1
  • 1
dreamerkumar
  • 1,540
  • 1
  • 18
  • 28
0

Alternative solution: check your watch for an empty file argument.

Here's an excerpt of my gruntfile

watch: {
  all: {
    options:{
      livereload: true
    },
    files: ['src/scss/*.scss', 'src/foo.html',, 'src/bar.html'],
    tasks: ['default']
  }
}

In my case, I could recreate the original poster's error on demand with the empty argument above.

Brian Muenzenmeyer
  • 1,026
  • 1
  • 7
  • 17