【发布时间】:2022-03-27 08:31:22
【问题描述】:
我的代码中的任务有问题。我有一些图像,我想使用“gulp-webp”模块将它们从 .jpg 转换为 .webp,但是当我在终端上运行 gulp 函数时,会出现以下错误:
[00:00:00]Starting 'versionWebp'...
[00:00:00]'versionWebp' errored after 8.92 msTypeError: dest.on is not a function
[00:00:00]at DestroyableTransform.Readable.pipe (D:\Cursos\Curso 06\FestivalMusica_inicio\node_modules\readable-stream\lib\_stream_readable.js:564:8)
at versionWebp (D:\Cursos\Curso 06\FestivalMusica_inicio\gulpfile.js:60:10)
at taskWrapper (D:\Cursos\Curso 06\FestivalMusica_inicio\node_modules\undertaker\lib\set-task.js:13:15)
at bound (node:domain:421:15)
at runBound (node:domain:432:12)
at asyncRunner (D:\Cursos\Curso 06\FestivalMusica_inicio\node_modules\async-done\index.js:55:18)
at processTicksAndRejections (node:internal/process/task_queues:78:11).
我的代码是这样的
const notify = require('gulp-notify');
const webp = require ('gulp-webp');
function versionWebp(){
return src('src/img/**/*')
.pipe( webp )
.pipe(gulp.dest('./build/img'))
.pipe(notify({message:'Version WEBP'}));
};
exports.versionWebp = versionWebp;
希望你能帮助我。
【问题讨论】:
-
使用
.pipe(webp())而不是.pipe(webp)。
标签: image compiler-errors gulp development-environment webp