Error: pngquant failed to build, make sure that libpng-dev is installed

遇到了一个很难搞的报错

新同事遇到的,最开始的体现是这样的
Error: pngquant failed to build, make sure that libpng-dev is installed
看到这个报错是很懵的,进入到对应的依赖目录下,发现pngquant.exe不存在

认为是依赖装得有问题,各种卸载重装,重新配置淘宝镜像,遇到新报错
Error: pngquant failed to build, make sure that libpng-dev is installed
Error: pngquant failed to build, make sure that libpng-dev is installed

› pngquant-bin@^5.0.0 run "node lib/install.js", root: "C:\\Users\\tophc\\Documents\\project\\code\\node_modules\\_pngquant-bin@5.0.2@pngquant-bin"
  ‼ Command failed: C:\Users\tophc\Documents\project\code\node_modules\_pngquant-bin@5.0.2@pngquant-bin\vendor\pngquant.exe --version


  ‼ pngquant pre-build test failed
  i compiling from source
  × Error: pngquant failed to build, make sure that libpng-dev is installed
    at C:\Users\tophc\Documents\project\code\node_modules\_execa@0.7.0@execa\index.js:231:11
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async Promise.all (index 0)
[npminstall:runscript:error] image-webpack-loader@5.1.0 › imagemin-pngquant@6.0.1 › pngquant-bin@^5.0.0 scripts.postinstall run "node lib/install.js" error: Error [RunScriptError]: Run "C:\Windows\system32\cmd.exe /d /s /c node lib/install.js" error, exit code 1
    at ChildProcess.<anonymous> (C:\Users\tophc\AppData\Roaming\npm\node_modules\cnpm\node_modules\runscript\index.js:96:21)
    at ChildProcess.emit (events.js:311:20)
    at maybeClose (internal/child_process.js:1021:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5) {
  name: 'RunScriptError',
  stdio: [Object],
  exitcode: 1
}
× Install fail! RunScriptError: post install error, please remove node_modules before retry!

关键提示:pngquant failed to build, make sure that libpng-dev is installed
我是很懵的,搜了一圈也没找到类似的问题,查到libpng-dev是在linux下安装的

从pngquant入手,这种情况其实就是系统环境缺了一个 dll文件, 导致 去安装 pngquant插件的时候报错


解决方法:
-> 前往 https://pngquant.org/ 下载pngquant库
Error: pngquant failed to build, make sure that libpng-dev is installed
->解压压缩包至C:\Windows\System32目录下

->管理员身份运行pngquant.exe
Error: pngquant failed to build, make sure that libpng-dev is installed

再安装就不会报错了

PS:以管理员运行pngquant.exe的时候,可能会遇到缺少vcruntime140.dll库的提示

从微软官方下载Visual C++ Redistributable for Visual Studio 2015。
地址:https://www.microsoft.com/zh-cn/download/details.aspx?id=48145

上一篇:拦截器与过滤器的使用,拦截器与AOP的区别


下一篇:github连接报"ssh: connect to host github.com port 22: Connection timed out"错误