L o a d i n g . . .
主打一个C++
文章详情

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

作者近期文章
  • 随手笔记
  • 主打一个C++   2025-01-11 20:02:01
  • 都2000000025年了。还有不能随意访问guthub的,仔细看。在国内其实是可以正常访问的,gfw并没屏蔽。这里给出其中一个简单直接的方法稳定访问。1. 随便百度一个”dn
提示
×
确定
数据库执行: 8次 总耗时: 0.01s
页面加载耗时: 



wechat +447752296473
wechat cpp-blog