javascript - Grunt watch 失败,并显示消息 "Running "watch"task Waiting... 警告 : Maximum call stack size exceeded "

标签 javascript angularjs gruntjs grunt-contrib-watch

我有下一个 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

但我仍然有这个错误:

Running "watch" task Waiting... Warning: Maximum call stack size exceeded

有人知道我做错了什么吗?

谢谢!

最佳答案

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

尝试删除您的 watch 配置并修改您的服务器任务以保持服务器处于事件状态:

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

关于javascript - Grunt watch 失败,并显示消息 "Running "watch"task Waiting... 警告 : Maximum call stack size exceeded ",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34596085/

相关文章:

javascript - 可以更改 Highcharts 钻取内的高度吗?

javascript - 使用 AngularJS 处理同一元素上的 ng-click 和 ng-dblclick

javascript - 仅 Grunt 目标子目录

sass - 使用 Foundation、Grunt、Sass 创建多个主题(css 文件)

javascript - 用于开发/生产环境的备用 grunt.js 任务

javascript - JSONP jQuery 中的回调函数

javascript - HTML、JS 和 CSS 如何协同工作

javascript - 保持函数调用直到单击

angularjs - Angular UI bootstrap Accordion - 展开创建可滚动和页面 "jump"

Angularjs:为什么在模板中绑定(bind)时自定义指令中的参数没有定义?