背景:切换npm镜像源是经常遇到的事,下面记录下具体操作命令
1. 打开终端运行"npm config get registry"命令来查看当前配置的镜像源
bash
npm config get registry
![](https://file.jishuzhan.net/article/1756187900053032961/89607f07597313180817d69e59378bd5.webp)
2. 修改成淘宝镜像源"https://registry.npmjs.org/"
bash
npm config set registry https://registry.npm.taobao.org/
![](https://file.jishuzhan.net/article/1756187900053032961/534797832ea5bb83ea0338e7678317ba.webp)
3. 查看修改结果,证明已修改成功
bash
npm config get registry
![](https://file.jishuzhan.net/article/1756187900053032961/8207cc163f35b009f4c1c0a4b309cb7a.webp)
npm 的镜像源已更改为你设置的镜像源,npm将使用新的镜像源下载包
4. 改回官方镜像源
bash
npm config set registry https://registry.npmjs.org/
![](https://file.jishuzhan.net/article/1756187900053032961/eced67632f8639729d05f576c36a851e.webp)
大功告成END!