|
在使用gulp4.0执行task的时候,gulpfile.js代码如下:
gulp.task("default",function () {
console.log("hello gulp");
});[15:28:03] Using gulpfile E:\guo\classproject\gulp\gulpfile.js [15:28:03] Starting 'default'... hello gulp [15:28:03] The following tasks did not complete: default [15:28:03] Did you forget to signal async completion? 解决方案: 本文采用的第2种,代码如下: gulp.task("default",function () {
return new Promise(function(resolve, reject) {
console.log("hello gulp");
resolve();
});
})或第3种,代码如下:gulp.task("default",function (done) {
console.log("hello gulp");
done();
}方法有五种,这五种除了最后一个都亲测没有问题。 本文翻译原文地址: https://stackoverflow.com/questions/36897877/gulp-error-the-following-tasks-did-not-complete-did-you-forget-to-signal-async 1. 返回一个stream 这种操作方式是用来新建task的,和3.x的用法一样。
在异步请求机制中,是有一个Promise对象的,它包含了请求的过程中所有内容。如下:
3. 返回一个回调函数 这个是最简单的一种方法,gulp会自动将这个回调函数作为一个参数返回到任务中,在完成的时候一定要调用这个函数。如下: gulp.task('default', gulp.series('server', (done) => done())) 4. 返回一个子进程child process 当我们只是执行一段纯js代码,没有用到node相关的方法时用这个方法。
5. 返回一个 RxJS Observable. 这个方法我没有过使用过,但是如果你是用RxJS 的时候,可以用这个方法。
|
||
|