I'm trying to minify images with imagemin, but it falls with an error. Can't understand what I've done wrong.
Here is my 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());
});
And an error message from console
$ 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)
Usually this error is thrown when you're trying to pipe()
something that's not a stream to gulp.dest()
.
I see in your code var imagemin = require('imagemin');
- are you sure you didn't mean to write var imagemin = require('gulp-imagemin');
? imagemin won't return a proper gulp
stream, but gulp-imagemin will.