云网牛站
所在位置:首页 > Linux教程 > 在Linux中安装libpng-dev以解决pngquant构建失败的问题

在Linux中安装libpng-dev以解决pngquant构建失败的问题

2020-02-07 15:45:45作者:曾秀珠稿源:云网牛站

如果你在Linux系统中遇到Error: pngquant failed to build, make sure that libpng-dev is installed(错误:pngquant构建失败,请确保已安装libpng-dev)问题,请按照以下解决方法操作。

在Linux中安装libpng-dev以解决pngquant构建失败的问题

 

前言

在尝试构建Nodejs应用程序时(在Linux Mint/Ubuntu/Debian系统中安装Node.js 13版本),我不断收到错误消息“Error: pngquant failed to build, make sure that libpng-dev is installed”,经过故障排除后,我意识到这是由构建时所需的依赖项应用程序缺失引起的。

> 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)

解决方法是使用操作系统软件包管理应用程序安装构建依赖项工具。

 

解决方法

针对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

安装完libpng-dev后,我得以成功构建。信息如下:

> uglifyjs-webpack-plugin@0.4.6 postinstall /home/ubuntu/koel/node_modules/webpack/node_modules/uglifyjs-webpack-plugin

> node lib/post_install.js

> node-sass@4.13.1 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

> gifsicle@3.0.4 postinstall /home/ubuntu/koel/node_modules/gifsicle

> node lib/install.js

gifsicle pre-build test passed successfully

> mozjpeg@5.0.0 postinstall /home/ubuntu/koel/node_modules/mozjpeg

> node lib/install.js

mozjpeg pre-build test passed successfully

> optipng-bin@3.1.4 postinstall /home/ubuntu/koel/node_modules/optipng-bin

> node lib/install.js

optipng pre-build test passed successfully

> pngquant-bin@4.0.0 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

注:我希望本文能帮助您使用pngquant开发工具作为依赖项来构建Nodejs应用程序。

 

相关主题

在Linux下安装Pngquant的三种方法:从存储库源代码及使用Cargo安装

精选文章
热门文章