yarn更换默认镜像地址

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

1、问题描述

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

2、问题分析

输入如下命令查看代理:

yarn config list

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

3、更换镜像

  • 输入如下命令删除代理

    yarn config delete proxy

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

    地址1: 设置镜像地址为淘宝(推荐):

    yarn config set registry https://registry.npmmirror.com

    地址2: 设置镜像地址为淘宝

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

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

    yarn config list

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

4、验证

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

 

posted on 2024-08-14 13:21  梁飞宇  阅读(63)  评论(0)    收藏  举报