90

我正在使用 nodejs v0.10.26 运行 Lion 10.9.2

我想在 sass 文件上设置一个自动编译并用 grunt 实时重新加载,没什么复杂的,但是......

运行时grunt watch出现以下错误

(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

这是 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' ]);

};

这是 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"
  }
}
4

6 回答 6

299

我终于发现了我在使用 SASS 时遇到的类似问题。我正在使用

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

诀窍是 Grunt 似乎不喜欢名字的重复。当我切换到

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

一切正常。

于 2014-03-14T15:31:44.730 回答
17

刚遇到这个问题。通过删除解决了它grunt.registerTask('watch', [ 'watch']);

于 2014-03-10T22:45:35.040 回答
11

我刚刚修复了由命令引起的类似错误“检测到递归 process.nextTick”:grunt server

解决方案?使用 sudo grunt serve 代替

于 2014-04-20T14:54:29.783 回答
1

你可以试试这个,它为我解决了这个问题,使用 Yeoman 1.3.3 和 Ubuntu 14.04 Grunt watch error - Waiting...Fatal error: watch ENOSPC

于 2014-11-14T20:13:07.557 回答
1

我什至在尝试安装 grunt 时都遇到了错误。运行 npm dedupe 解决了我的问题,如下所示:Grunt watch error - Waiting...Fatal error: watch ENOSPC

于 2016-06-18T21:17:53.463 回答
0

替代解决方案:检查您的手表是否有空文件参数

这是我的摘录gruntfile

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

就我而言,我可以使用上面的空参数按需重新创建原始海报的错误。

于 2014-12-10T21:01:44.623 回答