5

I am trying to compress images with grunt-contrib-imagemin ~0.9.4 in a node.js application. My config is:

    imagemin: {
        dynamic: {
            files: [{
                expand: true,
                cwd: 'server/static/img/',
                src: ['**/*.{jpg,gif,png}'],
                dest: '_public/incl/img/'
            }]
        }
    },

I systematically get a Error: spawn ENOENT in file somepath/someimage.png message. It fails at the first processed .png file. When I don't include .png files, it all works fine.

I have read somewhere that I should copy the image files first in the target directory as a workaround. I have tried this, but it does not solve the issue.

I am on Windows 7 32-bits and I am using grunt ~0.4.5. How can I solve this issue?

Jérôme Verstrynge
  • 57,710
  • 92
  • 283
  • 453

5 Answers5

7

Blow away node_modules/grunt-contrib-imagemin and try and do a npm install again. The node equivalent of “did you restart it”?

enter image description here

I see in their github repo they have a couple of issues related to pngs, but nothing like you are seeing.

Chad
  • 200
  • 4
3

just reinstall the image-webpack-loader. That's worked for me.

Terry
  • 31
  • 1
3

This rebuild fixed my problem.

Laravel Mix Issues Optimising Images in Sass Files | Andy Carter

 $ npm rebuild mozjpeg  
 $ npm rebuild gifsicle  
 $ npm rebuild optipng-bin
kujiy
  • 5,833
  • 1
  • 29
  • 35
1

Seems to be caused by a recent change in a package that imagemin is dependent on. The new setup doesn't support proxies until someone fixes it. https://github.com/kevva/download/issues/64

This thread suggests downgrading bin-build from 2.1.2 to 2.1.1

Roel
  • 58
  • 4
0

Just delete the node_modules folder and then run npm install or npm i to install all the modules again