为什么慢
在国内使用 npm安装的时候,默认是去 npm 官方镜像源获取需要安装的具体软件信息会非常缓慢. 可以使用命令查看当前源;
1 | npm config get registry |
国内大厂镜像源列表
npm 官方原始镜像网址是:https://registry.npmjs.org/
淘宝 npm 镜像:https://registry.npm.taobao.org
阿里云 npm 镜像:https://npm.aliyun.com
腾讯云 npm 镜像:https://mirrors.cloud.tencent.com/npm/
华为云 npm 镜像:https://mirrors.huaweicloud.com/repository/npm/
网易 npm 镜像:https://mirrors.163.com/npm/
中科院大学开源镜像站:http://mirrors.ustc.edu.cn/
清华大学开源镜像站:https://mirrors.tuna.tsinghua.edu.cn/
如何修改镜像源
幸运的是,国内大厂镜像站点可以提供我们免费使用,国内直接访问速度非常快,镜像站会实时更新,为我们节省下载过程中等待的时间;
- [临时] 修改
npm install 软件名 –registry https://registry.npm.taobao.org/ - [全局] 修改
npm config set registry https://registry.npm.taobao.org/