我有以下gulpfile.js,我通过命令行gulp消息执行:
var gulp = require('gulp');
gulp.task('message', function() {
console.log("HTTP Server Started");
});
我得到以下错误消息:
[14:14:41] Using gulpfile ~\Documents\node\first\gulpfile.js
[14:14:41] Starting 'message'...
HTTP Server Started
[14:14:41] The following tasks did not complete: message
[14:14:41] Did you forget to signal async completion?
我在Windows 10系统上使用gulp 4。下面是gulp——version的输出:
[14:15:15] CLI version 0.4.0
[14:15:15] Local version 4.0.0-alpha.2
我得到了同样的错误试图运行一个非常简单的SASS/CSS构建。
我的解决方案(可以解决相同或类似的错误)是简单地添加done作为默认任务函数的参数,并在默认任务的末尾调用它:
// Sass configuration
var gulp = require('gulp');
var sass = require('gulp-sass');
gulp.task('sass', function () {
gulp.src('*.scss')
.pipe(sass())
.pipe(gulp.dest(function (f) {
return f.base;
}))
});
gulp.task('clean', function() {
})
gulp.task('watch', function() {
gulp.watch('*.scss', ['sass']);
})
gulp.task('default', function(done) { // <--- Insert `done` as a parameter here...
gulp.series('clean','sass', 'watch')
done(); // <--- ...and call it here.
})
希望这能有所帮助!