I had the same issue with CentOS 7 even with libpng-devel
installed. It seems the package carries a precompiled binary program in node_modules/pngquant-bin/vendor/pngquant
which is somehow incompatible with the Linux installation (CentOS 7 latest).
I have made a solution to the problem by replacing this binary file with the one that is available for CentOS 7.
I am installing the official package pngquant
with yum
, first. Then I am installing the node modules. You can remove the node_modules
folder if you like prior to install action. Its not required, though.
The error will be shown as usual (the program file is not yet replaced):
⚠ The `node_modules/pngquant-bin/vendor/pngquant` binary doesn't seem to work correctly
⚠ pngquant pre-build test failed
ℹ compiling from source
✖ Error: pngquant failed to build, make sure that libpng-dev is installed
at ChildProcess.exithandler (child_process.js:206:12)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:877:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
However, after replacing the binary file everything should be fine.
sh
yum install libpng-devel pngquant
npm install
rm -rf node_modules/pngquant-bin/vendor/pngquant
ln -s /usr/bin/pngquant node_modules/pngquant-bin/vendor/pngquant
After that you can run any command you like, "imagemin:dynamic", etc. It should work properly.
Summary
Generally speaking, the problem appear to be inside the pngquant-bin
node package. This solution might help for other Linux distributions as well.
The solution itself is to install the officially supported version of pngquant
with the OS package manager and to replace the binary inside the pngquant-bin
vendor folder after its installation.
Update
In addition, there is a recent problem that is still related with pngquant
npm package. It seems that there is a buggy release of it - lock the required pngquant
package in your package.json
to older version (last properly running version for you).
libpng-dev
installed. On CentOS,yum install libpng-dev
should install it (not 100% sure about package name). – Correlate