21

I am trying to setup a react project. It has lot of dependencies and while downloading one of module it is throwing this error. This is on windows.

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

Output: ‼ unable to get local issuer certificate
pngquant pre-build test failed
compiling from source
pngquant pre-build test passed successfully
Error: pngquant failed to build, make sure that libpng-dev is installed

Promise Preston
  • 24,334
  • 12
  • 145
  • 143
Santosh b
  • 729
  • 1
  • 8
  • 19

5 Answers5

23

You didn't installed lib-png so that error is coming.Try to install lib-png first.

sudo apt-get install libpng-dev
npm install -g pngquant-bin
5

To expound more on @Mukesh's answer.

I experienced this issue when building a react project that uses the imagemin-pngquant package.

When I run npm install on the server I get the below error:

pngquant pre-build test failed
compiling from source
pngquant pre-build test passed successfully
Error: pngquant failed to build, make sure that libpng-dev is installed

Here's how I fixed it:

Install libpng-dev package on your machine/server:

sudo apt-get install libpng-dev

Add pngquant-bin package to your npm packages in the package.json file (if it doesn't yet exist):

"dependencies": {
  .
  .
  .
  "imagemin-pngquant": "^9.0.1",
  .
  .
  .
}

OR

Run the command to install the pngquant-bin package:

npm install imagemin-pngquant --save // to install the latest

OR

npm install imagemin-pngquant@9.0.1 --save // to install a specific version

Note: You can try npm install imagemin-pngquant@5.0.1 --save if you encounter issues with the latest version.

Now everything should be fine if you install the npm packages and build the project again using:

npm install
npm run build

That's all.

I hope this helps

Promise Preston
  • 24,334
  • 12
  • 145
  • 143
3

I faced the same issue:

Solution

Step 1

sudo apt-get update -y

Step 2

sudo apt-get install -y libpng-dev

These two steps sorted out my issue and working fine.

Nayana Chandran
  • 1,416
  • 1
  • 16
  • 30
2

On Ubuntu you can try to fix it with apt-get install -y libpango1.0-dev command, worked for older node v6

HydraOrc
  • 657
  • 7
  • 15
  • This was the fix for me on an old Vagrant box. Looks like it's expecting this or another dependent library but gives the "be sure libpng-dev is installed" error as a default message. – ahamilton9 Dec 01 '21 at 16:58
0

This worked for me on Windows:

  • Run Windows PowerShell as Admin
  • npm install --global --production windows-build-tools

If you have made any previous npm installation attempt which you most likely had, clean everything and then do a fresh dependency installation:

  • rm node_modules -R
  • rm package-lock.json
  • npm install

Good luck!

Rahul
  • 1