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