I kept getting an error message “Error: pngquant failed to build, make sure that libpng-dev is installed” while trying to build a Nodejs application. After a couple of minutes troubleshooting, I realized this was caused by missing dependency applications required at build time.
> node lib/install.js
⚠ The `/home/ubuntu/koel/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:294:12)
at ChildProcess.emit (events.js:198:13)
at maybeClose (internal/child_process.js:982:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
The fix was to install build dependency tools using the Operating system package management application.
Ubuntu / Debian:
sudo apt update
sudo apt install -y build-essential gcc make libpng-dev
CentOS Linux
sudo yum group install "Development Tools"
sudo yum -y install libpng-devel
Then I was able to build successfully.
> [email protected] postinstall /home/ubuntu/koel/node_modules/webpack/node_modules/uglifyjs-webpack-plugin
> node lib/post_install.js
> [email protected] postinstall /home/ubuntu/koel/node_modules/node-sass
> node scripts/build.js
Binary found at /home/ubuntu/koel/node_modules/node-sass/vendor/linux-x64-64/binding.node
Testing binary
Binary is fine
> [email protected] postinstall /home/ubuntu/koel/node_modules/gifsicle
> node lib/install.js
✔ gifsicle pre-build test passed successfully
> [email protected] postinstall /home/ubuntu/koel/node_modules/mozjpeg
> node lib/install.js
✔ mozjpeg pre-build test passed successfully
> [email protected] postinstall /home/ubuntu/koel/node_modules/optipng-bin
> node lib/install.js
✔ optipng pre-build test passed successfully
> [email protected] postinstall /home/ubuntu/koel/node_modules/pngquant-bin
> node lib/install.js
⚠ The `/home/ubuntu/koel/node_modules/pngquant-bin/vendor/pngquant` binary doesn't seem to work correctly
⚠ pngquant pre-build test failed
ℹ compiling from source
✔ pngquant pre-build test passed successfully
✔ pngquant built successfully
There you have it. I hope this article helped you build a Nodejs application with pngquant development tools as dependency.
More guides:
Best Books for Learning Node.js / AngularJS / ReactJS / ExpressJS
Show Comments