1. fatal: unable to access 'github.com/sohee-lee7/…': OpenSSL SSL_read:
在 PowerShell 下,执行 npm i
npm ERR! Command failed: git clone --depth=1 -q -b fix/ie-cannot-input-korean https://github.com/sohee-lee7/Squire.git在 Git Bash 下,执行
npm inpm ERR! Command failed: git clone --depth=1 -q -b fix/ie-cannot-input-korean https://github.com/sohee-lee7/Squire.gitnpm ERR! fatal: unable to access 'https://github.com/nhn/raphael.git/':在 Git Bash 下,执行
yarn
解决办法
$ git config --global url."git://".insteadOf https://
$ npm install
2. npm ERR! cb() never called npm ERR! This is an error with npm itself
解决办法
- 删除项目中的 package-lock.json 文件 和 node_modules 文件夹
- 清除 npm 缓存
$ npm cache clean --force - 安装依赖
$ npm install
3. Failed at the gifsicle@4.0.1 postinstall script.
接手了一个 React 项目,clone 完了之后,执行 npm i,报错,npm 源改为国内淘宝镜像还是报错,依赖的安装日志如下
原因分析
- 经过分析后发现是由于安装这些包时需要安装依赖包,而其中部分依赖包需要从 GitHub 上下载,而 GitHub 的资源库 DNS 有问题,导致这些依赖包无法安装而报错
解决办法
-
在本机 hosts 文件(路径为 C:\Windows\System32\drivers\etc)里添加 Github 相关域名的解析地址
192.30.255.112 gist.github.com 192.30.255.112 github.com 192.30.255.112 www.github.com 151.101.56.133 avatars0.githubusercontent.com 151.101.56.133 avatars1.githubusercontent.com 151.101.56.133 avatars2.githubusercontent.com 151.101.56.133 avatars3.githubusercontent.com 151.101.56.133 avatars4.githubusercontent.com 151.101.56.133 avatars5.githubusercontent.com 151.101.56.133 avatars6.githubusercontent.com 151.101.56.133 avatars7.githubusercontent.com 151.101.56.133 avatars8.githubusercontent.com 151.101.56.133 camo.githubusercontent.com 151.101.56.133 cloud.githubusercontent.com 151.101.56.133 gist.githubusercontent.com 151.101.56.133 marketplace-screenshots.githubusercontent.com 151.101.56.133 raw.githubusercontent.com 151.101.56.133 repository-images.githubusercontent.com 151.101.56.133 user-images.githubusercontent.com -
更改完 hosts 文件后记得刷新本地 DNS,打开 cmd,执行
ipconfig /flushdns -
删除依赖包,并清除 npm 缓存(指令:
npm cache clean --force) -
重新执行
npm install -
步骤1中列出来的 Github DNS 的内容可能会变动,如果执行完上述步骤还是报错,可以在 github 上搜索最新的 hosts 文件,尝试不同的 hosts 文件内容,直到执行成功为止