美文网首页React
Yarn 国内加速,修改镜像源

Yarn 国内加速,修改镜像源

作者: 三也视界 | 来源:发表于2020-11-30 09:10 被阅读0次

为什么慢

执行 yarn 各种命令的时候,默认是去 npm/yarn 官方镜像源获取需要安装的具体软件信息

以下命令查看当前使用的镜像源

yarn config get registry
image.png

默认源地址在国外,从国内访问的速度肯定比较慢

yarn save 软件名 --registry https://registry.npm.taobao.org/  # 临时换源yarn config set registry https://registry.npm.taobao.org     # 全局修改

yrm的使用

yrm YARN registry manager
yrm 不仅可以快速切换镜像源,还可以测试自己网络访问不同源的速度

安装 yrm(管理员下运行)

npm install -g yrm
image.png

mac下报错

sh-3.2# npm install -g yrm
npm ERR! code ENOTFOUND
npm ERR! errno ENOTFOUND
npm ERR! network request to https://registry.npmjs.org/yrm failed, reason: getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network 
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly.  See: 'npm help config'

npm ERR! A complete log of this run can be found in:
npm ERR!     /var/root/.npm/_logs/2020-11-25T15_00_08_999Z-debug.log

安装cnpm

npm install -g cnpm --registry=https://registry.npm.taobao.org

然后使用cnpm安装

cnpm install -g yrm
image.png

列出当前可用的所有镜像源

yrm ls    
image.png

测试访问速度

yrm test taobao
image.png

如何修改镜像源

阿里旗下维护着一个完整的 npm 镜像源 https://registry.npm.taobao.org/ 同样适用于 yarn

1. 临时修改

yarn save 软件名 --registry https://registry.npm.taobao.org/

2. 全局修改

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

3. 使用第三方软件快速修改、切换 yarn 镜像源

使用淘宝镜像源

yrm use taobao
image.png

更多用法查看 yrm GitHub

配置 Electron 源,添加环境变量

ELECTRON_MIRROR
http://npm.taobao.org/mirrors/electron/

执行npm install -g electron


image.png

相关文章

  • Yarn 国内加速,修改镜像源

    为什么慢 执行 yarn 各种命令的时候,默认是去 npm/yarn 官方镜像源获取需要安装的具体软件信息 以下命...

  • yarn 国内加速,修改镜像源

    为什么慢执行 yarn 各种命令的时候,默认是去 npm/yarn 官方镜像源获取需要安装的具体软件信息 以下命令...

  • Linux修改Docker国内镜像源

    docker默认的源为国外官方源,下载速度较慢,可修改为国内镜像源进行加速 方案一: 修改daemon.json配...

  • Composer 国内加速,修改镜像源

    为什么慢由于默认情况下执行 composer 各种命令是去国外的 composer 官方镜像源获取需要安装的具体软...

  • Composer 国内加速,修改镜像源

    修改镜像源 查看全局源 composer config -g -l(没有 -g 查看当前) 阿里源 https:/...

  • linux合集

    修改CentOSyum源国内镜像

  • Docker-3 国内镜像源

    国内镜像源 Docker 加速器 国内比较好的镜像源:网易蜂巢、aliyun和daocloud daocloud....

  • docker问题汇总

    如何加速docker下载镜像 登陆阿里,获取镜像加速地址,按操作修改镜像源https://cr.console.a...

  • Ubuntu 20.04 install docker

    更换阿里云镜像源 Docker CE 镜像 安装指定版本 Docker 镜像加速 修改加速镜像配置文件 启动doc...

  • docker安装ubuntu 16.04

    1、docker 设置国内镜像源 国内加速地址有: Docker中国区官方镜像https://registry.d...

网友评论

    本文标题:Yarn 国内加速,修改镜像源

    本文链接:https://www.haomeiwen.com/subject/bmniiktx.html