npm安装image-webpack-loader报错解决办法


安装

  1. 首先先安装
npm install image-webpack-loader --save-dev
  1. 然后顺利报错:
> cwebp-bin@5.1.0 postinstall D:\...\code\node_modules\cwebp-bin
> node lib/install.js

  ‼ getaddrinfo ENOENT raw.githubusercontent.com
  ‼ cwebp pre-build test failed
  i compiling from source
  × Error: Command failed: C:\Windows\system32\cmd.exe /s /c "./configure --disable-shared --prefix="D:\工作\code\hcs_template02\node_modules\cwebp-bin\vendor" --bindir="D:\工作\code\hcs_template02\node_modules\cwebp-bin\vendor""

这里没连上raw.githubusercontent.com,可能是域名解析的问题。所以要在ip查询网查一下raw.githubusercontent.com
的ip地址,然后写在系统的hosts文件里。

windows的host文件在C:\Windows\System32\drivers\etc,直接在文件结尾加上:

151.101.108.133       raw.githubusercontent.com

先卸载原来的,再重新安装:

npm uninstall image-webpack-loader
npm install image-webpack-loader --save-dev

安装成功

  √ pngquant pre-build test passed successfully
PS D:\工作\code\hcs_template02> npm install image-webpack-loader --save-dev

> cwebp-bin@5.1.0 postinstall D:\工作\code\hcs_template02\node_modules\cwebp-bin
> node lib/install.js

  √ cwebp pre-build test passed successfully

> gifsicle@5.1.0 postinstall D:\...\node_modules\gifsicle
> node lib/install.js

  √ gifsicle pre-build test passed successfully

> mozjpeg@7.0.0 postinstall D:\...\node_modules\mozjpeg
> node lib/install.js

  √ mozjpeg pre-build test passed successfully

> optipng-bin@7.0.0 postinstall D:\...\node_modules\optipng-bin
> node lib/install.js

  √ optipng pre-build test passed successfully

> pngquant-bin@6.0.0 postinstall D:\...\node_modules\pngquant-bin
> node lib/install.js


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM