GUlp - 以下任务未完成

GUlp - following tasks did not complete

我正在使用 gulp 4,并且我有以下 gulpfile.js:

'use strict';
var gulp = require('gulp'), del = require('del');

gulp.task('copy-fonts', () => {
    return gulp.src(['node_modules/ng/resources/fonts/**/*'])
        .pipe(gulp.dest('apps/src/assets/fonts'));
});

gulp.task('clean-copy', () => {
    del(['apps/src/assets/fonts']);
});

gulp.task('copy-assets', gulp.series(['clean-copy', 'copy-fonts']), (done) => {
    console.log("Gulp is running...");
    done();
});

当我 运行 这个命令:gulp copy-assets,我得到以下错误:

[11:59:06] The following tasks did not complete: copy-assets
[11:59:06] Did you forget to signal async completion?

在此代码中:

gulp.task('copy-assets', gulp.series(['clean-copy', 'copy-fonts']), (done) => {
    console.log("Gulp is running...");
    done();
});

任务有三个参数 - 即 gulp v3 语法,而不是 gulp 4. 所以将其更改为

gulp.task('copy-assets', gulp.series(['clean-copy', 'copy-fonts'], (done) => {
    console.log("Gulp is running...");
    done();
));

done return 现在在 gulp.series 参数中。也做这个改变,我认为这是必要的:

gulp.task('clean-copy', (cb) => { 
  del(['apps/src/assets/fonts'] ); 
  cb(); 
});