【问题标题】:grunt-contrib-watch Unbound Recursion Errorgrunt-contrib-watch 未绑定递归错误
【发布时间】:2014-11-23 19:29:20
【问题描述】:

我得到了和这个人一样的错误信息:

grunt-contrib-watch causing Maximum call stack size exceeded

在这个 grunt 文件上运行“grunt watch”时:

module.exports = function(grunt) {

    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        uglify: {
            options: {
                banner: '//Copyright (c) 2014 <%= pkg.author %>. All Rights Reserved.\n'
                },
            build: {
                files: {
                    "Static/JavaScript/<%= pkg.name %>/AppLogic.Min.js": ["Static/JavaScript/<%= pkg.name %>/AppLogic.js"]
                }
            }
        },
        less: {
            production: {
                options: {
                    cleancss: true
                },
                files: {
                    "Static/Css/<%= pkg.name %>/Style.Min.css": ["Static/Css/<%= pkg.name %>/Style.css"]
                }
            }
        },
        watch: {
            scripts: {
                files: ["Static/JavaScript/<%= pkg.name %>/AppLogic.js"],
                tasks: ["uglify"]
            },
            styles: {
                files: ["Static/Css/<%= pkg.name %>/Style.css"],
                tasks: ["less"]
            }
        }
    });

    grunt.loadNpmTasks("grunt-contrib-less");
    grunt.loadNpmTasks("grunt-contrib-uglify");
    grunt.loadNpmTasks("grunt-contrib-watch")

    grunt.registerTask("default", ["uglify", "less"]);
    grunt.registerTask("watch", ["watch"]);
};

看答案,我的问题似乎与其他问题的原因不同,但肯定有问题。

运行不带参数的 grunt 运行良好,因此“uglify”和“less”似乎构造正确。

运行“grunt watch:scripts”或“grunt watch:styles”也会导致错误。

有什么想法吗?

PS:grunt/grunt-cli 安装在我的应用程序本地,而不是全局安装在我的机器上。不要认为解决这个问题有什么不同,但为了完整起见......

此外,在弹出错误之前,我多次收到以下警告:

(节点)警告:检测到递归 process.nextTick。这将在下一个版本的节点中中断。请使用 setImmediate 进行递归延迟。

【问题讨论】:

标签: gruntjs grunt-contrib-watch


【解决方案1】:

啊,问题不是我的“监视”任务结构,而是这一行:

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

以不同于其参数的方式命名任务解决了问题,如下所示:

grunt.registerTask("watch_", ["watch"]);

感谢以下答案,抱歉重复:

warning: Recursive process.nextTick detected

【讨论】:

    猜你喜欢
    • 2015-01-25
    • 1970-01-01
    • 1970-01-01
    • 2017-06-12
    • 2023-03-12
    • 1970-01-01
    • 2015-11-13
    • 2014-11-19
    • 1970-01-01
    相关资源
    最近更新 更多