使用yarn安装依赖包出现“There appears to be trouble with your network connection. Retrying...”超时的提醒

发布时间 2023-12-14 09:48:49作者: Qubernet

我们在使用yarn安装依赖包文件的时候,可能会出现“There appears to be trouble with your network connection. Retrying...”超时的提醒,很有可能是因为yarn默认的镜像地址为国外,因此慢(超时)就说得过去了……

1、问题描述

我们在使用yarn安装依赖包文件的时候,可能会出现“There appears to be trouble with your network connection. Retrying...”超时的提醒,如下图所示:

image

2、问题分析

出现该超时的问题,很有可能是因为yarn默认的镜像地址为国外,因此慢(超时)就说得过去了……

输入如下命令查看代理:

yarn config list

image

此时,我们发现镜像的地址为国外,获取的速度肯定就慢了,因此我们可以将镜像设置为国内,比如淘宝。

3、更换镜像

  • 输入如下命令删除代理

    yarn config delete proxy
    

    image

  • 输入如下命令更换为淘宝镜像

    yarn config set registry https://registry.npm.taobao.org
    

    image

  • 再次输入如下命令查看代理

    yarn config list
    

    image

    此时,我们可以看到镜像地址为国内的淘宝了。

4、验证

最后,我们再次使用yarn安装依赖包速度就正常了,如下图所示:

image