I am trying to compress my images for the production server but getting an error in running the gulp-imagemin task.
This is my gulp task:
gulp.task('images', function(){
gulp.src('builds/development/images/**/*.*')
.pipe(gulpif(env === 'production', imageMin({
progressive:true,
svgoPlugins:[{removeViewBox:false}],
use:[pngCrush()]
})))
.pipe(gulpif(env === 'production', gulp.dest('builds/production/images')))
.pipe(connect.reload());
});
I am getting the following trace:
events.js:141
throw er; // Unhandled 'error' event
^
Error: spawn UNKNOWN
at exports._errnoException (util.js:870:11)
at ChildProcess.spawn (internal/child_process.js:298:11)
at Object.exports.spawn (child_process.js:362:9)
at ret.catch.module.exports.promise (C:\Users\user\desktop\workflows\node_modules\gulp-imagemin\node_modules\imagemin-jpegtran\node_modules\exec-buffer\node_modules\execa\index.js:139:26)
at C:\Users\user\desktop\workflows\node_modules\gulp-imagemin\node_modules\imagemin-jpegtran\node_modules\exec-buffer\index.js:35:15
Can someone please have a look and try to provide some solution.
Thanks in advance.
I had the same problem on a production server and I've tried:
imageminwithout parameters;The solution was to delete the
node_modulesfolder and runnpm installagain. Strangely enough, it worked as a charm!