Node.js imagemin on CentOS

I am trying to use Node.js imagemin to compress a lot of images on my server. I like to use imagemin because I know how to point it to specific directories.

I am using CentOS 6 and when I run my file I get the error:

node_modules / imagemin / node_modules / imagemin-pngquant / node_modules / pngquant-bin / vendor / pngquant: /lib64/libc.so.6: version `GLIBC_2.14 'not found

Also, when I installed imagemin with npm install imagemin

I got the error:

Error: pngquant failed to build, make sure libpng-dev is installed

Any ideas on what I can do to fix this problem?

+5


source to share


5 answers


(The de facto issue has already been resolved in the comments - but for the sake of completion and future generations, I'm posting the actual answer).

Error: pngquant failed to build, make sure libpng-dev is installed

This error means that the system does not have a development library libpng

that is required to install the imagemin

Node.JS module . To install it on CentOS 6, you need to run this command:



yum install libpng-devel

Please note that both package managers (here - yum

) and package name ( libpng-devel

) may differ between different Linux distributions.

+10


source


I had the same problem with CentOS 7, even with one installed libpng-devel

. The package seems to contain a pre-compiled binary in node_modules/pngquant-bin/vendor/pngquant

, which is somehow incompatible with Linux installation (CentOS 7 latest).

I solved the problem by replacing this binary with the one available for CentOS 7.

First, I install the official package pngquant

with yum

. Then I install the node modules. You can delete the folder node_modules

if you like prior to installation. However, this is not required.

The error will be displayed as usual (the program file has not been replaced yet):

⚠ 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, 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

In general, the problem ends up inside the pngquant-bin

node package . This solution may help other Linux distributions as well.

The solution itself should install the official version pngquant

> using the OS Package Manager and replace the binary inside the vendor folder pngquant-bin

after installing it.

Update

Also, there is a recent issue that is still related to the pngquant

npm package . There seems to be a bug in its release - lock the required package pngquant

in yours package.json

to an older version (the latest correctly working version for you).

+8


source


The previous solutions didn't work for me. I am using Centos 7.4

When executing

# npm install

      

I got the error:

✖ Error: pngquant failed to build, make sure libpng-dev is installed '

When trying to install libpng-devel

, it says that it is already installed.

Decision

Please update your nodejs & npm version if it is using an older version.

I have updated to

Nodejs version

[root@hosting ~]# node -v

      

v8.10.0

npm version

[root@hosting ~]# npm -v

      

5.7.1

Check the installed libpng-devel on your server.

[root@hosting ~]# rpm -qa |grep libpng

      

Libpng-1.5.13-7.el7_2.x86_64

Libpng-development-1.5.13-7.el7_2.x86_64

If you are using epel repo, it will install the latest version. For additional check of libpng release

[root@hosting ~]# yum list |grep libpng

      

I have installed

yum install libpng12-1.2.50-10.el7.x86_64 libpng12-devel-1.2.50-10.el7.x86_64

      

displaced node modules

mv node_modules node_modules_bak

      

Then enter

# npm install

      

+6


source


This is how I solved the problem for my case:

Delete node_modules

:

rm -rf node_modules

      

Install the following dependencies:

sudo dnf install libpng-devel pngquant gcc make libpng12 libpng12-devel

      

Rebuild dependencies. I am using yarn

:

yarn

      

0


source


in my case i am using a CentOS instance on Amazon WS and here i faced the same problem. I solved this by installing libpng12 and libpng12-devel (yum install libpng12 libpng12-devel), then running yarn install (or npm install) and the packages installed correctly.

This is simple!

0


source







All Articles