2021 npm安装Electron失败解决方法

  • Post author:
  • Post category:其他


npm直接安装Electron时,直接报如下错误


PS D:\Git\0.Repo\0.Gitee\electron-third-party-applications-notify> npm install --save-dev electron
npm ERR! code 1
npm ERR! path D:\Git\0.Repo\0.Gitee\electron-third-party-applications-notify\node_modules\electron
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c node install.js
npm ERR! RequestError: read ECONNRESET
npm ERR!     at ClientRequest.<anonymous> (D:\Git\0.Repo\0.Gitee\electron-third-party-applications-notify\node_modules\got\source\request-as-event-emitter.js:178:14)
npm ERR!     at Object.onceWrapper (node:events:514:26)
npm ERR!     at ClientRequest.emit (node:events:406:35)
npm ERR!     at ClientRequest.origin.emit (D:\Git\0.Repo\0.Gitee\electron-third-party-applications-notify\node_modules\@szmarczak\http-timer\source\index.js:37:11)
npm ERR!     at TLSSocket.socketErrorListener (node:_http_client:447:9)
npm ERR!     at TLSSocket.emit (node:events:394:28)
npm ERR!     at emitErrorNT (node:internal/streams/destroy:193:8)
npm ERR!     at emitErrorCloseNT (node:internal/streams/destroy:158:3)
npm ERR!     at processTicksAndRejections (node:internal/process/task_queues:83:21)
npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Anran\AppData\Local\npm-cache\_logs\2021-12-03T12_59_14_854Z-debug.log

查看报错日志后,发现是访问404

之前npm使用的是淘宝源的,于是切换回默认的即可安装成功

设置为

淘宝

源:

npm config set registry http://registry.npm.taobao.org/

设置为默认源:

npm config set registry https://registry.npmjs.org/

但是安装速度很慢,因为是国外的,可以使用魔法加快下载

欢迎关注交流



版权声明:本文为qq_35787254原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。