安装electron时安装失败解决

错误描述:

在安装 electron 的时候,使用官方推荐的如下命令:

npm install --save-dev electron

结果报错如下

在这里插入图片描述

npm ERR! code 1
npm ERR! path D:\AWQW\electron\demo-test\node_modules\electron
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node install.js
npm ERR! RequestError: connect ETIMEDOUT 39.102.194.95:443
npm ERR!     at ClientRequest.<anonymous> (D:\AWQW\electron\demo-test\node_modules\got\dist\source\core\index.js:970:111)
npm ERR!     at Object.onceWrapper (node:events:510:26)
npm ERR!     at ClientRequest.emit (node:events:402:35)
npm ERR!     at ClientRequest.origin.emit (D:\AWQW\electron\demo-test\node_modules\@szmarczak\http-timer\dist\source\index.js:43:20)
npm ERR!     at TLSSocket.socketErrorListener (node:_http_client:447:9)
npm ERR!     at TLSSocket.emit (node:events:390:28)
npm ERR!     at emitErrorNT (node:internal/streams/destroy:157:8)
npm ERR!     at emitErrorCloseNT (node:internal/streams/destroy:122:3)
npm ERR!     at processTicksAndRejections (node:internal/process/task_queues:83:21)
npm ERR!     at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1146:16)

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Administrator\AppData\Local\npm-cache\_logs\2022-12-21T08_31_06_218Z-debug-0.log

分析:

  • 首先考虑是否是由于要下载的东西在国外,导致的下载失败,所以开启了FQ软件,依旧无效,下载很快,在下载完成的时候,node_modules 包自动删除并开始报错。
  • 其次考虑是否是 node 与 npm 版本不一致导致的,所以更新了 npm 的版本,结果依旧无效。
  • 无中文路径

解决:

使用 cnpm 进行安装

cnpm i electron --save-d

在这里插入图片描述

成功安装!!!


PS:cnpm 的安装方法

npm install -g cnpm --registry=https://registry.npm.taobao.org

推荐这种方式安装是因为既不会影响npm命令,又不用每次都写淘宝地址进行依赖包的安装

posted on   霍志杰  阅读(1596)  评论(0编辑  收藏  举报  

相关博文:
阅读排行:
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示