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