Gruntfile.js - 抛出错误'递归process.nextTick检测到“ [英] Gruntfile.js - Throwing error 'Recursive process.nextTick detected"

查看:94
本文介绍了Gruntfile.js - 抛出错误'递归process.nextTick检测到“的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我根据官方的说明定义了一个简单的Gruntfile.js,但我收到警告当我运行grunt watch('$ grunt watch')或者grunt默认任务('$ grunt')时。

错误是:


<节点>警告:递归process.nextTick检测。这会在下一个节点版本中打破
。请使用setImmediate递归
延期。

我已阅读相关的StackOverflow问题并在这里回答: grunt throw"递归process.nextTick检测" ,但这并没有解决我的问题。



我的Gruntfile.js是:

  module.exports = function (grunt){
grunt.initConfig({
pkg:grunt.file.readJSON('package.json'),
concat:{
options:{
分隔符:';'
},
dist:{'b $ b src:['client / app / ** / *。js'],
dest:'client / dist / <%= pkg.name%> .js'
}
},
uglify:{
options:{
banner:'/ *!< %= pkg.name%><%= grunt.template.today(dd-mm-yyyy)%> * / \ n'
},
dist:{
档案:{
'dist /<%= pkg.name%> .min.js':['<%= concat.dist.dest%>']
}
}
},
jshint:{
files:['client / app / ** / *。js','server / ** / *。js'],
选项:{
//用于重写JSHint默认值的选项
globals:{
jQuery:true,
cons ole:true,
module:true,
document:true
}
}
},
watch:{
files:[' <%jshint.files%>'],
tasks:['jshint']
}
});

grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-concat');

grunt.registerTask('default',['watch']);
grunt.registerTask('test',['jshint']);
grunt.registerTask('build-dev',['jshint','concat']);
grunt.registerTask('build',['jshint','concat','uglify']);

};

解决方案

行。我想到了。和dagnabbit,这个bug与我从 复制的Gruntfile相同。



节点不喜欢 watch 说明引用 jshint.files 属性,然后调用 jshint 任务。相反,我把这些文件明确地放在下面。在更改以下行(带上下文)后:

  watch:{
files:['client / app / * * / *。js','server / ** / *。js'],
tasks:['jshint']
}

grunt手表和默认任务(默认任务执行手表任务),它没有任何警告!


I have defined a simple Gruntfile.js per the official instructions and yet I am getting a warning when I run the grunt watch ('$ grunt watch') or grunt default task ('$ grunt ').

The error is:

(node) warning: Recursive process.nextTick detected. This will break in the next version of node. Please use setImmediate for recursive deferral.

I have read the related StackOverflow question and answer here: grunt throw "Recursive process.nextTick detected", but that didn't resolve my issue.

My Gruntfile.js is:

module.exports = function(grunt) {
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    concat: {
      options: {
        separator: ';'
      },
      dist: {
        src: ['client/app/**/*.js'],
        dest: 'client/dist/<%= pkg.name %>.js'
      }
    },
    uglify: {
      options: {
        banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n'
      },
      dist: {
        files: {
          'dist/<%= pkg.name %>.min.js': ['<%= concat.dist.dest %>']
        }
      }
    },
    jshint: {
      files: ['client/app/**/*.js', 'server/**/*.js'],
      options: {
        // options here to override JSHint defaults
        globals: {
          jQuery: true,
          console: true,
          module: true, 
          document: true
        }
      }
    },
    watch: {
      files: ['<% jshint.files %>'],
      tasks: ['jshint']
    }
  });

  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-concat');

  grunt.registerTask('default', ['watch']);
  grunt.registerTask('test', ['jshint']);
  grunt.registerTask('build-dev', ['jshint', 'concat']);
  grunt.registerTask('build', ['jshint', 'concat', 'uglify']);

};

解决方案

OK. I figured it out. And dagnabbit, the bug was in the same Gruntfile that I copied hither from thither.

Node did NOT like the watch instructions to reference the jshint.files property and then call the jshint task. So instead, I put the files in explicitly as follows. After changing the following lines (with context):

 watch: {
       files: ['client/app/**/*.js', 'server/**/*.js'],
       tasks: ['jshint']
     }

the grunt watch and default tasks (the default task was performing the watch task), it worked without any warnings!

这篇关于Gruntfile.js - 抛出错误'递归process.nextTick检测到“的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆