我有以下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
对于那些试图使用gulp进行本地部署的人,下面的代码将有所帮助
var gulp = require("gulp");
var yaml = require("js-yaml");
var path = require("path");
var fs = require("fs");
//Converts yaml to json
gulp.task("swagger", done => {
var doc = yaml.safeLoad(fs.readFileSync(path.join(__dirname,"api/swagger/swagger.yaml")));
fs.writeFileSync(
path.join(__dirname,"../yourjsonfile.json"),
JSON.stringify(doc, null, " ")
);
done();
});
//Watches for changes
gulp.task('watch', function() {
gulp.watch('api/swagger/swagger.yaml', gulp.series('swagger'));
});