【发布时间】:2020-05-24 09:28:41
【问题描述】:
链接到这个问题 = Gulp error: The following tasks did not complete: Did you forget to signal async completion?
当我尝试使用以下代码运行“watch”时,它会出错:
gulp.task('watch', async function() {
var watchJs = gulp.watch(paths.js, ['scripts']),
watchJson = gulp.watch(paths.json, ['json']),
watchHtml = gulp.watch(paths.html, ['html']),
watchCss = gulp.watch(paths.css, ['css']),
watchFonts = gulp.watch(paths.fonts, ['fonts']),
watchAssets = gulp.watch(paths.assets, ['assets']),
onChanged = function(event) {
console.log('File ' + event.path + ' was ' + event.type + '. Running tasks...');
}
watchJs.on('change', onChanged);
watchJson.on('change', onChanged);
watchHtml.on('change', onChanged);
watchCss.on('change', onChanged);
watchFonts.on('change', onChanged);
watchAssets.on('change', onChanged);
});
错误提示:Error: watching src/js/**/*.js: watch task has to be a function (optionally generated by using gulp.parallel or gulp.series)
但我不知道如何解决这个问题。我尝试将异步放在 gulp.task('watch', async function() { 但这不起作用
【问题讨论】:
标签: gulp gulp-watch