yarn 错误There appears to be trouble with your network connection. Retrying

先交代环境:
Ubuntu18
yarn --version
1.22.4
npm -v
6.14.4
node -v
v12.16.3

执行操作后报错信息
#yarn install
yarn install v1.22.4
[1/4] Resolving packages…
[2/4] Fetching packages…
info There appears to be trouble with your network connection. Retrying…
info There appears to be trouble with your network connection. Retrying…
info There appears to be trouble with your network connection. Retrying…
error An unexpected error occurred: “https://registry.npm.taobao.org/prettier/download/prettier-2.0.5.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fprettier%2Fdownload%2Fprettier-2.0.5.tgz: unexpected end of file”.

info If you think this is a bug, please open a bug report with the information provided in “/root/zbg_contract_website_h5_app_new/yarn-error.log”.

这里yarn install 过程中会有一个Fetching:
[2/4] Fetching packages…
[################################################################################] 1598/1602

这里有一个校验过程,这个文件你直接放到浏览器里是可以下载下来的。
所以这里使用 yarn add 直接添加这个依赖
yarn add
https://registry.npm.taobao.org/prettier/download/prettier-2.0.5.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fprettier%2Fdownload%2Fprettier-2.0.5.tgz

如图
图片1
加载成功了,然后跑yarn install 就很顺利pass了。

另外info提示网络问题,我看网络上绝大部份都是改成淘宝源。这个有可能解决一部分问题,但是还会有一些不管用的。
info There appears to be trouble with your network connection. Retrying…

这里有一个方法:绑定host
直接将绑定源节点 域名+IP写进host
你直接 dig registry.npm.taobao.org
图2
然后将得到的节点IP绑定到host,再执行命令的时候会解决一部分网络的问题。

完!

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐