常见的前端安装错误raw.githubusercontent.com optipng-bin

699 阅读1分钟

前后端初次安装项目的时候常见的一个错误是,由于raw.githubusercontent.com无法连接造成一个package无法安装,于是报错。

比如

warning Error running install script for optional dependency: "D:\\code\\my-project\\node_modules\\mozjpeg: Command failed.
Exit code: 1
Command: node lib/install.js
Arguments:
Directory: D:\\code\\my-project\\node_modules\\mozjpeg
Output:
getaddrinfo ENOENT raw.githubusercontent.com
mozjpeg pre-build test failed
compiling from source
Error: Command failed: C:\\WINDOWS\\system32\\cmd.exe /s /c \"autoreconf -fiv\"
'autoreconf' �����ڲ����ⲿ���Ҳ���ǿ����еij���
�����������


    at D:\\code\\my-project\\node_modules\\bin-build\\node_modules\\execa\\index.js:231:11
[9/11] ⠄ optipng-bin
[-/11] ⡀ waiting...
[-/11] ⡀ waiting...
[-/11] ⡀ waiting...
warning Error running install script for optional dependency: "D:\\code\\my-project\\node_modules\\optipng-bin: Command failed.
Exit code: 1
Command: node lib/install.js
Arguments:
Directory: D:\\code\\my-project\\node_modules\\optipng-bin
Output:
getaddrinfo ENOENT raw.githubusercontent.com
optipng pre-build test failed
compiling from source
Error: Command failed: C:\\WINDOWS\\system32\\cmd.exe /s /c \"./configure --with-system-zlib --prefix=\"D:\\code\\my-project\\node_modules\\optipng-bin\\vendor\" --bindir=\"D:\\code\\my-project\\node_modules\\optipng-bin\\vendor\"\"

解决思路: 需要把github链接改成淘宝的镜像链接(最新npmmirror.com)

解决办法:

  1. 找到yarn的cache文件夹,命令 yarn cache dir; 结果 C:\Users\dellxps\AppData\Local\Yarn\Cache\v6
  2. 直接用viscode打开上述文件夹
  3. 搜索 raw.githubusercontent.com/imagemin
  4. 全部替换成 npmmirror.com/mirrors