我正在尝试为节点安装imagemin-pngquant模块:
https://www.npmjs.org/package/imagemin-pngquant
但是,当我运行命令时
npm install imagemin-pngquant --save-dev
我得到以下错误:
warn : pngquant pre-build test Failed info : compiling from source error : Error: pngquant Failed to build,make sure that libpng-dev is installed at ChildProcess.exithandler (child_process.js:637:15) at ChildProcess.EventEmitter.emit (events.js:98:17) at maybeClose (child_process.js:735:16) at Socket.<anonymous> (child_process.js:948:11) at Socket.EventEmitter.emit (events.js:95:17) at Pipe.close (net.js:466:12)
如何安装pngquant所需的libpng-dev库?
我在Windows下安装gulp-imagemin时遇到类似的丢失libpng-dev的问题.我发现Windows中不存在libpng-dev,仅适用于MacOS和Linux.这是我收到的错误消息:
原文链接:https://www.f2er.com/windows/364482.htmlenter > node lib/install.js ‼ Request to https://raw.github.com/imagemin/pngquant-bin/v3.0.0/vendor/win/pngquant.exe Failed ‼ pngquant pre-build test Failed i compiling from source × Error: pngquant Failed to build,make sure that libpng-dev is installed at ChildProcess.exithandler (child_process.js:744:12) at ChildProcess.emit (events.js:110:17) at maybeClose (child_process.js:1008:16) at Socket.<anonymous> (child_process.js:1176:11) at Socket.emit (events.js:107:17) at Pipe.close (net.js:476:12)
所以,我试过安装pngquant-bin
npm install --save-dev pngquant-bin
但得到或多或少相同的错误信息.请注意版本号3.0.0.
然后我尝试像这样安装pngquant(没有-dev):
npm install --save-dev pngquant --msvs_version=2013
它成功安装了pngquant版本2.0.0.之后我还可以安装gulp-imagemin.
我不确定2013年的图书馆版本是否在这里发挥了作用.