Aakash Thakur
Aakash Thakur

Reputation: 3895

gulp-imagemin task run gives error

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.

Upvotes: 1

Views: 1585

Answers (1)

Goran Stoyanov
Goran Stoyanov

Reputation: 2311

I had the same problem on a production server and I've tried:

  • Running imagemin without parameters;
  • Checking all possible permission issues;
  • Changing node version to latest;

The solution was to delete the node_modules folder and run npm install again. Strangely enough, it worked as a charm!

Upvotes: 0

Related Questions