npm、yarn改镜像地址
2020-04-13 本文已影响0人
沸腾Shark
npm默认仓库地址:https://registry.npmjs.org/
yarn默认仓库地址:https://registry.yarnpkg.com
yarn和npm镜像是一致的,只不过yarn优化了npm的操作而已,所以当npm更换了源地址,使用yarn add安装package时,如果npm源地址里不含此package的镜像,则也会直接报错:
image.png
npm、yarn查看源地址
npm config get registry
yarn config get registry
npm config ls
pm、yarn更换源地址
npm config set registry <源地址url> //更换npm镜像源地址
yarn config set registry <源地址url> //更换yarn镜像源地址
npm config set <某插件> <源地址url> //仅更改某插件的npm源地址
yarn config set <某插件> <源地址url> //仅更改某插件的yarn源地址
镜像源地址部分
npm --- https://registry.npmjs.org/
npm --- https://registry.npm.taobao.org/
yarn --- https://registry.yarnpkg.com/
yarn --- https://registry.npm.taobao.org/
cnpm --- https://r.cnpmjs.org/
taobao --- https://registry.npm.taobao.org/
nj --- https://registry.nodejitsu.com/
rednpm --- https://registry.mirror.cqupt.edu.cn/
npmMirror --- https://skimdb.npmjs.com/registry/
deunpm --- http://registry.enpmjs.org/
使用nrm源管理工具管理npm及yarn源##
nrm是yarn及npm的源管理工具,类似于:nvm是node的版本管理工具。
1. 安装nrm:
npm install -g nrm //npm全局安装nrm
yarn add nrm -g //yarn全局安装nrm
2. nrm使用
- 查看可选源
nrm ls
- 查看当前源
nrm current
- 切换源
nrm use <源名(非url,如taobao)> //使用源的名称切换源,源的名称即为nrm ls中列出的键值对(源名:url)中的key
- 添加源
nrm add <源名> <源地址url>
- 删除源
nrm del <源名>
- 测试源速度
nrm test <源名>