gulp报错:The following tasks did not complete: task_name
2019-05-13 15:05
781 查看
问题描述
在如下代码运行时报错:
gulp.task('A' , function(){ console.log('A') }); gulp.task('B' , function(){ //运行B之前先去运行A console.log('B') }); gulp.task('my-task', gulp.series("A","B",function(){ console.log("AB") }))
报错如下:
D:\me\gulp\gulp-test>gulp task [14:36:02] Using gulpfile D:\me\gulp\gulp-test\gulpfile.js [14:36:02] Starting 'task'... [14:36:02] Starting 'A'... A [14:36:02] The following tasks did not complete: task, A [14:36:02] Did you forget to signal async completion?
分析问题
在不使用文件流的情况下,向task的函数里传入一个名叫cb的回调函数,以结束task,如下代码所示:
gulp.task('test', cb => { console.log('Hello World!'); cb(); });
解决问题
- 添加
async
和await
异步方法处理:
gulp.task('A' , async function(){ await console.log('A') }); gulp.task('B' , async function(){ await console.log('B') }); gulp.task('my-task', gulp.series("A","B", async function(){ await console.log("AB") }))
- 添加结束回调
done()
gulp.task('A' , function(){ console.log('A') done() }); gulp.task('B' , function(done){ console.log('B') done() }); gulp.task('my-task', gulp.series("A","B", function(done){ console.log("AB") done() }))
- 最终打印结果
[15:00:29] Using gulpfile D:\me\gulp\gulp-test\gulpfile.js [15:00:29] Starting 'my-task'... [15:00:29] Starting 'A'... A [15:00:29] Finished 'A' after 7.08 ms [15:00:29] Starting 'B'... B [15:00:29] Finished 'B' after 2.26 ms [15:00:29] Starting '<anonymous>'... AB [15:00:29] Finished '<anonymous>' after 2.02 ms [15:00:29] Finished 'my-task' after 20 ms
相关文章推荐
- gulp4.0报错‘The following tasks did not complete: ...’
- The following DIMM modules(s) did not pass CPU memory test Please remove the modules(s)then plug aga
- "Format" did not complete normally. Please see the log for more information. 解决
- ERROR:Place:866 - Not enough valid sites to place the following IOBs: IO Standard: Name = LVC (20
- ocp 047-141 Evaluate the following SQL statement:SELECT product_name || 'it's not available for orde
- tag 'select', field 'list', name 'did': The requested list key '#id' could not be resolved as a c
- "Format" did not complete normally. Please see the log for more information. 解决
- The `brew link` step did not complete successfully
- Android应用程序上传错误The package name of your apk may not begin with any of the following values:[com.android, com.google, android, co
- [Fiddler] ReadResponse() failed: The server did not return a complete response for this request. Server returned 0 bytes.
- android 老是弹出 "Copy" did not complete normally. Please see the log for more information.
- MATLAB编程->Reading capture using Tshark did not work for the following reason
- 成功解决 ValueError: feature_names mismatch training data did not have the following fields
- Error converting document: task did not complete within timeout解决方法
- "Copy" did not complete normally. Please see the log for more information
- Could not load the following font :pdfFontName : STSong-Light问题
- The `brew link` step did not complete successfully
- WCF问题集锦:ReadResponse failed: The server did not return a complete response for this request.
- 如何解决The following assembly name can not be resolved automatically 提示
- emulator: ERROR: You did not provide the name of an Android Virtual Device