gruntjs - grunt-contrib-watch 导致超出最大调用堆栈大小

标签 gruntjs grunt-contrib-watch

当我执行清理任务 (grunt clean) 时,一切都按预期工作,但是当我运行监视任务 (grunt test) 时,出现以下错误:

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

这是我的 grunt 文件

module.exports = (grunt) ->

  grunt.initConfig
    pkg: grunt.file.readJSON('package.json')

    clean: ['tmpDir/']

    watch:
      options:
        spawn: false
      src:
        tasks: ['clean']
        files: [
          src: 'client/assets/strings/en/str.coffee'
        ]

  # plugins
  grunt.loadNpmTasks('grunt-contrib-clean')
  grunt.loadNpmTasks('grunt-contrib-watch')

  # tasks
  grunt.registerTask('test', ['watch'])

这是我的 package.json 文件:

{
  "author": "Your Name <Your Email>",
  "name": "app-name",
  "description": "Application description",
  "version": "0.0.1",
  "homepage": "",
  "repository": {
    "type": "git",
    "url": ""
  },
  "engines": {
    "node": "~0.10.28"
  },
  "scripts": {
    "start": "muffin server"
  },
  "dependencies": {
    "coffee-script": "~1.1.2",
    "express": "~3.0.6",
    "chai": "~1.4.2",
    "underscore": "~1.4.3",
    "wd": "0.0.27"
  },
  "devDependencies": {
    "express": "~3.0.6",
    "grunt": "^0.4.5",
    "grunt-contrib-coffee": "^0.11.1",
    "grunt-contrib-copy": "^0.6.0",
    "grunt-contrib-less": "^0.11.4",
    "grunt-contrib-watch": "^0.6.1",
    "requirejs": "~2.0.1"
  }
}

我使用 --verbose 运行时的输出如下: 注意:用 *** 替换了基本路径

Initializing
Command-line options: --verbose

Reading "gruntfile.coffee" Gruntfile...OK

Registering Gruntfile tasks.
Reading package.json...OK
Parsing package.json...OK
Initializing config...OK

Registering "grunt-contrib-clean" local Npm module tasks.
Reading /***/node_modules/grunt-contrib-clean/package.json...OK
Parsing /***/node_modules/grunt-contrib-clean/package.json...OK
Loading "clean.js" tasks...OK
+ clean

Registering "grunt-contrib-watch" local Npm module tasks.
Reading /***/node_modules/grunt-contrib-watch/package.json...OK
Parsing /***/node_modules/grunt-contrib-watch/package.json...OK
Loading "watch.js" tasks...OK
+ watch
Loading "gruntfile.coffee" tasks...OK
+ test

Running tasks: test

Running "test" task

Running "watch" task
Waiting...
Verifying property watch exists in config...OK
Verifying property watch.src.files exists in config...OK
Warning: Object #<Object> has no method 'indexOf'

Running "watch" task
Waiting...
Verifying property watch exists in config...OK
Verifying property watch.src.files exists in config...OK
Warning: Object #<Object> has no method 'indexOf'

... many of these

Running "watch" task
Waiting...
Verifying property watch exists in config...OK
Verifying property watch.src.files exists in config...OK
Warning: Object #<Object> has no method 'indexOf'

(node) warning: Recursive process.nextTick detected. This will break in the next version of node. Please use setImmediate for recursive deferral.
(node) warning: Recursive process.nextTick detected. This will break in the next version of node. Please use setImmediate for recursive deferral.
... many of these
(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

最佳答案

我终于想出了我在 spell 上遇到的类似问题。我在用

grunt.registerTask('拼写', ['拼写']); 诀窍在于 Grunt 似乎不喜欢名称的重复。当我切换到

grunt.registerTask('拼写检查', ['拼写']); 一切正常。

这对你有帮助吗

关于gruntjs - grunt-contrib-watch 导致超出最大调用堆栈大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25998898/

相关文章:

javascript - Grunt.js grunt-contrib-watch 事件不触发 grunt.task.run

java - 无法使用 Maven 运行 npm grunt bower

javascript - Grunt - 同时执行和监视应用程序

javascript - 大多数 Grunt 任务都找不到

node.js - 如何根据更改的文件修改 grunt watch 任务?

javascript - 导入的 sass 文件出现 grunt "undefined variable"错误

gruntjs - 如果找不到文件,如何让 gruntjs 跳过 eslint 任务?

gruntjs - grunt-useref 和 grunt-usemin 之间的区别?

node.js - Csslint:多次使用背景图像

javascript - 用于渲染下划线模板的 grunt contrib-jst 格式不正确