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