我正在尝试为节点安装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库?
答案 0 :(得分:3)
在Windows下安装gulp-imagemin时,我遇到了类似的缺少libpng-dev的问题。我发现Windows中不存在libpng-dev,仅适用于MacOS和Linux。这是我收到的错误消息:
enter > 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-binnpm 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年的图书馆版本是否在这里发挥了作用。
答案 1 :(得分:2)
使用Windows Power Shell作为管理员和npm install --global --production windows-build-tools
如果您以前曾经做过任何npm
安装尝试-您一定已经做过,现在要阅读这些文章-您必须清理所有内容,并重新进行依赖安装:
$ rm node_modules -R
$ rm package-lock.json
$ npm install
祝你好运!