一、npm
- 查看当前的镜像源。
```
npm config get registry
```
- 设置为淘宝源
```
npm config set registry https://registry.npm.taobao.org
```
- 还原默认源
```
npm config set registry https://registry.npmjs.org/
二、Yarn
1.yarn的安装
```
npm install -g yarn
```
- 查看当前镜像源
```
yarn config get registry
```
- 设置为淘宝镜像源
```
yarn config set registry https://registry.npmmirror.com
```
- 切回原镜像源
```
yarn config set registry https://registry.yarnpkg.com