Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ReactJS: Pngquant failed to build, make sure that libpng-dev is installed

Tags:

npm

reactjs

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

like image 605
Santosh b Avatar asked Jul 11 '18 06:07

Santosh b


4 Answers

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
like image 78
Mukesh Burnwal Mike Avatar answered Oct 18 '22 10:10

Mukesh Burnwal Mike


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 [email protected] --save // to install a specific version

Note: You can try npm install [email protected] --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

like image 27
Promise Preston Avatar answered Oct 18 '22 10:10

Promise Preston


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

like image 2
HydraOrc Avatar answered Oct 18 '22 11:10

HydraOrc


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.

like image 2
Nayana Chandran Avatar answered Oct 18 '22 09:10

Nayana Chandran