文章详情
npm速度慢的解决方案集合
Posted on 2025-04-01 12:11:27 by 主打一个C++
我是在安装electron时太慢了。从来没有这么慢过。顺便发n个解决方法。
1. 使用淘宝镜像
临时使用淘宝镜像
npm install electron --save-dev --registry=https://registry.npm.taobao.org
全局配置淘宝镜像
npm config set registry https://registry.npm.taobao.org
如果你需要切换回官方镜像源,可以使用以下命令:
npm config set registry https://registry.npmjs.org/
2. 使用Yarn
安装:
npm install -g yarn
使用Yarn安装Electron:
yarn add electron --dev
3. 使用cnpm
cnpm是淘宝团队提供的npm客户端镜像,速度也较快。你可以通过以下步骤来使用cnpm:
安装cnpm
npm install -g cnpm --registry=https://registry.npm.taobao.org
使用cnpm安装Electron
cnpm install electron --save-dev
4. 配置npm使用HTTP而不是HTTPS
有时候使用HTTP协议可以更快,但不推荐长期使用,因为HTTP不安全。
npm config set registry http://registry.npm.taobao.org
5.配置HTTP代理
npm config set proxy http://127.0.0.1:1989
配置HTTPS代理
npm config set https-proxy http://127.0.0.1:1989
6.使用国内云服务提供商的镜像
阿里云镜像:
npm config set registry https://registry.aliyuncs.com
华为云镜像:
npm config set registry https://repo.huaweicloud.com/repository/npm/
还有很多,这些够用了。最后还是选择了代理方法。
*转载请注明出处:原文链接:https://cpp.vin/page/133.html