npm默認倉庫地址:https://registry.npmjs.org/
yarn默認倉庫地址:https://registry.yarnpkg.com
yarn和npm鏡像是一致的,只不過yarn優(yōu)化了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 <源名>