grunt-contrib-watch causing Maximum call stack size exceeded

不羁岁月 提交于 2019-12-07 15:39:39

问题


When I execute the clean task (grunt clean), everything works as expected but when I run the watch task (grunt test), I get the following error:

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

Here's my gruntfile

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'])

Here's my package.json file:

{
  "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"
  }
}

The output when I run with --verbose is the following: Note: replaced base path with ***

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

回答1:


The files property takes an Array of file pattern strings. You've supplied an object it doesn't know how to interpret.

Change this:

files: [
  src: 'client/assets/strings/en/str.coffee'
]

To this:

files: [
  'client/assets/strings/en/str.coffee'
]



回答2:


I finally figured out a similar problem I was having with spell. I was using

grunt.registerTask('spell', [ 'spell']); The trick was that Grunt doesn't seem to like the repetition in names. When I switch to

grunt.registerTask('spellCheck', [ 'spell']); Everything worked as it should.

may this help you



来源:https://stackoverflow.com/questions/25998898/grunt-contrib-watch-causing-maximum-call-stack-size-exceeded

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!