简体   繁体   English

Gulp:您是否忘记发出异步完成错误信号

[英]Gulp: Did you forget to signal async completion error

I have had to recently upgrade to gulp 4 and I found this error:我最近不得不升级到 gulp 4,我发现了这个错误:

Did you forget to signal async completion?您是否忘记发出异步完成信号?

My gulpfile looks as follows:我的 gulpfile 如下所示:

(function () {
  "use strict";

  const demoPath = "demo/node_modules/style";
  var cleanCSS = require("gulp-clean-css");
  const del = require("del");
  const fs = require("fs");
  var gulp = require("gulp");
  var sass = require("gulp-sass");
  var path = require("path");
  var rename = require("gulp-rename");

  gulp.task("clean", () => {
    return del.sync([
      "**.js", "!gulpfile.js"
    ]);
  }, async  function(done){
    console.log("This is clean task!");
    done();
  });

  function clean() {
    return gulp.src("src/**/*.scss")
      .pipe(sass())
      .pipe(cleanCSS({}))
      .pipe(rename({
        extname: ".min.css"
      }))
      .pipe(gulp.dest("./dist"));
  }

  gulp.task("build", gulp.series("clean"), function(done) {
    console.log("Started");
    done();
  });

}());

I read that with gulp 4 we would need to return a promise, a stream or callback etc. I did try to add the callback in the function and execute them but I still see the error. I read that with gulp 4 we would need to return a promise, a stream or callback etc. I did try to add the callback in the function and execute them but I still see the error.

Could anyone point me to a direction here?谁能给我指个方向?

Thanks for reading.谢谢阅读。

This code is gulp v3 syntax:此代码为 gulp v3 语法:

  gulp.task("build", gulp.series("clean"), function(done) {
    console.log("Started");
    done();
  });

gulp.task() no longer takes 3 arguments, only two. gulp.task()不再需要 3 个 arguments,只需两个。 So change to:所以改为:

  gulp.task("build", gulp.series("clean", function(done) {
    console.log("Started");
    done();
  }));

where gulp.series has the two (or more) functions inside it.其中gulp.series有两个(或更多)功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Gulp您是否忘记了异步完成信号 - Gulp did you forget to signal async completion Gulp错误:您是否忘记了异步完成信号? - Gulp error: Did you forget to signal async completion? Gulp 4迁移错误(您是否忘记发信号异步完成?) - Gulp 4 Migration Errors (Did you forget to signal async completion?) Gulp 错误:“以下任务未完成;您是否忘记发出异步完成信号” - Gulp Error: "The following tasks did not complete; Did you forget to signal async completion" Gulp4 - 任务没有完成,忘记发信号异步完成 - Gulp4 - tasks did not complete and forget to signal async completion 我如何解决此错误'以下任务未完成:默认,您是否忘记了异步完成信号? ' - how can i solve this error 'The following tasks did not complete: default, Did you forget to signal async completion? ' Gulp 抛出错误。 您是否忘记发出异步编译信号。? - Gulp is throwing an error. Did you forget to signal async compilation.? Gulp 4 Sass忘记信号异步完成 - Gulp 4 sass forget to signal async completion gulpjs - “您是否忘记发出异步完成信号?” 从 uglifyjs 切换到 terser 之后 - gulpjs - "Did you forget to signal async completion?" after switching from uglifyjs to terser Gulp 4.0信号异步完成错误,尽管返回了流 - Gulp 4.0 signal async completion error despite returning stream
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM