简体   繁体   中英

Error: spawn ENOENT for png files when using grunt-contrib-imagemin

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?

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

在此输入图像描述

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

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

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 

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM