【问题标题】:Grunt watch fails with message " Running "watch" task Waiting... Warning: Maximum call stack size exceeded "Grunt 监视失败并显示消息“正在运行”监视任务等待...警告:超出最大调用堆栈大小“
【发布时间】:2020-03-19 04:52:46
【问题描述】:

我有下一个 Gruntfile.js

module.exports = function(grunt) {
    
    'use strict';

    // Load Grunt tasks declared in the package.json file
    require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

    // Configure Grunt
    grunt.initConfig({

        // Grunt express - our webserver
        // https://github.com/blai/grunt-express
        express: {
            all: {
                options: {
                    bases: 'xxxxxxxx',
                    port: 9000,
                    hostname: '0.0.0.0',
                    livereload: true
                }
            }
        },

        // grunt-watch will monitor the projects files
        // https://github.com/gruntjs/grunt-contrib-watch
        watch: {
            all: {
                    files: ['**/*.html'],
                    options: {
                        livereload: true
                }
            }
        },

        // grunt-open will open your browser at the project's URL
        // https://www.npmjs.org/package/grunt-open
        open: {
            all: {
                path: 'http://localhost:9000/index.html'
            }
        },

        // grunt-open will install the bower components defined on the bower.json file
        // https://www.npmjs.com/package/grunt-bower-install-simple
        'bower-install-simple': {
            options: {
                color: true,
                directory: 'assets/bower_components'
            },
            'prod': {
                options: {
                    production: true
                }
            },
            'dev': {
                options: {
                    production: false
                }
            }
        }
    });

    // Creates the `server` task
    grunt.registerTask('server', [
        'express',
        'open',
        'watch'
        ]);
};

{
  "engines": {
    "node": ">= 0.10.0"
  },
  "devDependencies": {
    "grunt-bower-install-simple": "~1.2.0",
    "grunt-contrib-watch": "~0.6.1",
    "grunt": "~0.4.5",
    "matchdep": "~1.0.0",
    "grunt-express": "~1.4.1",
    "grunt-open": "~0.2.3"
  }
}

我尝试解决方案:Grunt watch error - Waiting...Fatal error: watch ENOSPC

但我仍然有这个错误:

正在运行“监视”任务等待中...警告:最大调用堆栈大小 超过

有谁知道我做错了什么?

谢谢!

【问题讨论】:

  • 您正在运行哪个 grunt 任务来获取错误?您是否还有其他已编辑的任务,或者这真的是您的完整 gruntfile?
  • 我正在运行 grunt 服务器,这是完整的 grunt 文件,谢谢
  • 好的 - 你能把你的 package.json 也贴出来吗?
  • 好的,我加到帖子里了

标签: javascript angularjs gruntjs grunt-contrib-watch


【解决方案1】:

grunt-express 的文档看来,设置livereload 会生成一个监视任务。我认为此任务与您自己的 watch 任务相冲突。

尝试删除您的手表配置并修改您的服务器任务以保持服务器处于活动状态:

// Creates the `server` task
grunt.registerTask('server', [
    'express',
    'open',
    'express-keepalive'
    ]);

【讨论】:

  • 非常感谢,这修复了任务!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-04-26
  • 2012-07-24
  • 2021-09-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多