我根据官方 instructions 定义了一个简单的 Gruntfile.js然而,当我运行 grunt watch('$ grunt watch')或 grunt 默认任务('$ grunt ')时,我收到警告。
错误是:
(node) warning: Recursive process.nextTick detected. This will break in the next version of node. Please use setImmediate for recursive deferral.
我已阅读相关的 StackOverflow 问题和答案:grunt throw "Recursive process.nextTick detected" ,但这并没有解决我的问题。
我的 Gruntfile.js 是:
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']);
};
最佳答案
好的。我想到了。还有 dagnabbit,这个 bug 就在我从 thither 复制的同一个 Gruntfile 中。 .
Node 不喜欢 watch 指令来引用 jshint.files 属性,然后调用 jshint 任务。因此,我将文件显式放入,如下所示。更改以下行后(带上下文):
watch: {
files: ['client/app/**/*.js', 'server/**/*.js'],
tasks: ['jshint']
}
grunt 监视和默认任务(默认任务是执行监视任务),它工作时没有任何警告!
关于javascript - Gruntfile.js - 抛出错误 'Recursive process.nextTick detected",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23900010/