gulp: Did you forget to signal async completion? 解决方案
背景

学习gulp的前端自动化构建,按照示例代码,跑了一个简单的task,控制台打出如下提示:
The following tasks did not complete: testGulp
Did you forget to signal async completion?
查阅Stack Overflow,表示有五种解决办法,在这里提供一种更简单的改法。
问题重现
原代码:
const gulp = require('gulp');
gulp.task('testGulp', () => {
console.log('Hello World!');
});
控制台报错:
The following tasks did not complete: testGulp
Did you forget to signal async completion?
解决方法,使用 async 和 await。
修改后代码
const gulp = require('gulp');
gulp.task('testGulp', async() => {
await console.log('Hello World!');
});
控制台输出正常
[13:18:37] Starting 'testGulp'...
Hello World!
[13:18:37] Finished 'testGulp' after 2.77 ms
附官方方法
在不使用文件流的情况下,向task的函数里传入一个名叫done的回调函数,以结束task,如下代码所示:
gulp.task('testGulp', done => {
console.log('Hello World!');
done();
});
done回调函数的作用是在task完成时通知Gulp(而不是返回一个流),而task里的所有其他功能都纯粹依赖Node来实现。
gulp: Did you forget to signal async completion? 解决方案的更多相关文章
- gulp遇到错误:The following tasks did not complete: default Did you forget to signal async completion?
运行之后会像下面一样报这个错误,因为事按着一个视频来写的,所以 原本的gulpfile.js如下 const gulp = require('gulp') gulp.task('default',() ...
- gulp更新4.0后的报错(gulp报Did you forget to signal async completion?)
本文首发于青云工作室 原文链接为 https://qystudio.ltd/posts/55153.html 缘起 今天我升级了gulp到4.0,在git三件套之后,网站并没有更新,我便登录了gith ...
- gulp4.0 存在的错误信息 The following tasks did not complete: default,Did you forget to signal async completion?
当gulp为如下代码的时候: // 以下代码会执行在node环境下 const gulp = require( "gulp" ); // 创建一个gulp的任务 gulp.task ...
- gulp#4.0 Did you forget to signal async completion?
异常截图 解决方案: https://stackoverflow.com/questions/36897877/gulp-error-the-following-tasks-did-not-compl ...
- npm--npm+gulp发布至私服,报错E503解决方案
由于项目共享组件库的需要,我们搭建了npm私有服务器,供本公司几个项目可以访问.组件库使用gulp+webpack+npm进行打包构建,私服使用的是 Verdaccio直接搭建的,一键式傻瓜搭建,贼好 ...
- gulp学习-metamask前端使用
https://www.gulpjs.com.cn/docs/getting-started/ ,这个是3.9.0版本 后面发现安装的版本是4.0.0,看下面这个: https://github.co ...
- gulp几个常见问题及解决方案
1. 找不到local gulp 报错代码: $ gulp [23:29:31] Local gulp not found in [23:29:31] Try running: npm install ...
- Gulp自动化构建的基本使用
Study Notes 本博主会持续更新各种前端的技术,如果各位道友喜欢,可以关注.收藏.点赞下本博主的文章. Gulp 用自动化构建工具增强你的工作流程! gulp 将开发流程中让人痛苦或耗时的任务 ...
- 01 nodejs MVC gulp 项目搭建
文本内容 使用generator-express创建nodejs MVC DEMO 使用gulp实时编译项目 npm安装二进制包,无须再编译wget https://nodejs.org/dist/v ...
随机推荐
- [HAOI2015]按位或
题目 好神的题啊 我们发现我们求这个东西如果常规\(dp\)的话可以建出一张拓扑图来,但是边的级别高达\(3^n\),转移的时候还要解方程显然不能通过本题 我们考虑神仙的\(min-max\)容斥 设 ...
- leetcode 217. Contains Duplicate 287. Find the Duplicate Number 442. Find All Duplicates in an Array 448. Find All Numbers Disappeared in an Array
后面3个题都是限制在1-n的,所有可以不先排序,可以利用巧方法做.最后两个题几乎一模一样. 217. Contains Duplicate class Solution { public: bool ...
- 基于AppDomain的"插件式"开发
很多时候,我们都想使用(开发)USB式(热插拔)的应用,例如,开发一个WinForm应用,并且这个WinForm应用能允许开发人员定制扩展插件,又例如,我们可能维护着一个WinService管理系统, ...
- error: OpenCV Error: Assertion failed (0 <= roi.x && 0 <= roi.width && roi.x + roi.width <= m.cols && 0 <= roi.y && 0 <= roi.height && roi.y + roi.height <= m.rows) in cv::Mat::Mat
问题原因: You are probably working outside of the image dimensions. Does any of the values you pass to t ...
- [Luogu P1120]小木棍·加强版
#\(\mathcal{Description}\) 乔治有一些同样长的小木棍,他把这些木棍随意砍成几段,直到每段的长都不超过 \(50\) . 现在,他想把小木棍拼接成原来的样子,但是却忘记了自己开 ...
- vmstat命令参数详解
转自:https://www.cnblogs.com/ggjucheng/archive/2012/01/05/2312625.html vmstat命令是最常见的Linux/Unix监控工具,可以展 ...
- P2434 [SDOI2005]区间
题目描述 现给定n个闭区间[ai, bi],1<=i<=n.这些区间的并可以表示为一些不相交的闭区间的并.你的任务就是在这些表示方式中找出包含最少区间的方案.你的输出应该按照区间的升序排列 ...
- 【ThinkingInC++】75、多重继承
第九章 多重继承 9.2 接口继承 Intertfacees.cpp /** * 书本:[ThinkingInC++] * 功能:接口继承Interfaces.cpp * 时间:2014年10月28日 ...
- 自适应和响应式布局的区别,em与rem
自适应布局:不同终端上显示的文字,图片,等位置排版都是一样的,只是大小不同. 响应式布局:通过媒体查询监听屏幕大小的变化,做出响应式的改变,在不同设备可能展现不同的样式效果. em:是相对其父元素的. ...
- 沟通修炼 I型沟通->U型沟通
沟通的目的 来源:邀请你看<01课 沟通管理:学会U型沟通,沟通效率翻倍>https://url.cn/51YaHrq?sf=uri 案例: 女友太困,不想早起去上班 你的回答? 正确做法 ...