我正在尝试使用 imagemin 缩小图像,但出现错误。无法理解我做错了什么。
这是我的 gulpfile
'use strict';
var gulp = require('gulp');
var imagemin = require('imagemin');
var clean = require('gulp-clean');
gulp.task('img', function () {
return gulp.src('src/img/**')
.pipe(imagemin())
.pipe(gulp.dest('build/img'));
});
gulp.task('clean', function() {
console.log('-----------удаляю build');
return gulp.src('build', {read: false})
.pipe(clean());
});
以及来自控制台的错误消息
$ gulp img
(node:14312) fs: re-evaluating native module sources is not supported. If you are using the graceful-fs module, please update it to a more recent version.
[22:10:20] Using gulpfile Z:\a\gulpfile.js
[22:10:20] Starting 'img'...
[22:10:20] 'img' errored after 26 ms
[22:10:20] TypeError: dest.on is not a function
at DestroyableTransform.Readable.pipe (Z:\a\node_modules\vinyl-fs\node_modules\readable-stream\lib\_stream_readable.js:516:8)
at Gulp.<anonymous> (Z:\a\gulpfile.js:9:6)
at module.exports (Z:\a\node_modules\orchestrator\lib\runTask.js:34:7)
at Gulp.Orchestrator._runTask (Z:\a\node_modules\orchestrator\index.js:273:3)
at Gulp.Orchestrator._runStep (Z:\a\node_modules\orchestrator\index.js:214:10)
at Gulp.Orchestrator.start (Z:\a\node_modules\orchestrator\index.js:134:8)
at C:\Users\Artur\AppData\Roaming\npm\node_modules\gulp\node_modules\gulp-cli\lib\versioned\^3.7.0\index.js:46:20
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickCallback (internal/process/next_tick.js:98:9)
at Function.Module.runMain (module.js:577:11)