gulp-imagemin: Task Failing on notFoundError node_modules\cross-spawn\lib\enoent.js

Running gulp-imagemin task throws the following error:

events.js:160
      throw er; // Unhandled 'error' event
      ^
Error: The system cannot find the path specified.

    at notFoundError (C:\dev\test\node_modules\execa\node_modules\cross-spawn\lib\enoent.js:11:11)
    at verifyENOENT (C:\dev\test\node_modules\execa\node_modules\cross-spawn\lib\enoent.js:46:16)
    at ChildProcess.cp.emit (C:\dev\test\node_modules\execa\node_modules\cross-spawn\lib\enoent.js:33:19)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)

Environment Details npm 4.1.2 node 6.9.4 win32 x64 (windows 7) cmdr admin console gulp 3.9.1 gulp-imagemin 3.1.1

Gulp task

var gulp = require('gulp');
var imagemin = require('gulp-imagemin');

var src = {
	img : './src/img/**/*',
}

var public = {
	img : './public/img'
}

gulp.task( 'images', function() {
 	gulp.src(src.img)
 		.pipe(imagemin())
 		.pipe(gulp.dest(public.img))
 		.pipe(notify({ message: 'gulp images complete', onLast: true }))
});

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 4
  • Comments: 20 (2 by maintainers)

Most upvoted comments

Have you try to install npm inside the gulp-imagemin directory:

cd path\to\the\project\node_modules\gulp-imagemin
npm i

Then re-try. Good luck 😉

Same but if we try to pass arguments to imagemin it works:

  • plugins []
  • options {}
.pipe(imagemin([], {}))

The install.js script from some plugins did not run, so executing this fixed it for me:

node node_modules/jpegtran-bin/lib/install.js
node node_modules/optipng-bin/lib/install.js

Have you try to install npm inside the gulp-imagemin directory:

cd path\to\the\project\node_modules\gulp-imagemin
npm i

Then re-try. Good luck 😉

Its work

could ‘fix’ it by using yarn instead of npm to install dependencies… not sure if this is a real fix, or just coincidence though

Thanks a lot crick64. It works.

crick64 commented on 7 Aug - This healp me. Thanks!

@montalvomiguelo, in your example no plugin will run and therefore no images will be minified.

Have you try to install npm inside the gulp-imagemin directory:

cd path\to\the\project\node_modules\gulp-imagemin
npm i

Then re-try. Good luck 😉

Worked like a charm!! Thanks so much!

Have you try to install npm inside the gulp-imagemin directory:

cd path\to\the\project\node_modules\gulp-imagemin
npm i

Then re-try. Good luck 😉

Great, Its working. …

@crick64 Muchas grácias 😃