【问题标题】:How to fix this npm "code 1" error installing electron如何修复这个 npm \"code 1\" 安装电子的错误
【发布时间】:2022-09-26 17:13:50
【问题描述】:

使用此命令安装电子时:

npm install electron --save-dev

我收到以下错误:

npm ERR! code 1
npm ERR! path C:\\Users\\ducpm34\\Desktop\\04_01_2022\\electron-app\\node_modules\\electron
npm ERR! command failed
npm ERR! command C:\\Windows\\system32\\cmd.exe /d /s /c node install.js
npm ERR! RequestError: self signed certificate in certificate chain
npm ERR!     at ClientRequest.<anonymous> (C:\\Users\\ducpm34\\Desktop\\04_01_2022\\electron-app\\node_modules\\got\\source\\request-as-event-emitter.js:178:14)
npm ERR!     at Object.onceWrapper (node:events:510:26)
npm ERR!     at ClientRequest.emit (node:events:402:35)
npm ERR!     at ClientRequest.origin.emit (C:\\Users\\ducpm34\\Desktop\\04_01_2022\\electron-app\\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: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! A complete log of this run can be found in:
npm ERR!     C:\\Users\\ducpm34\\AppData\\Local\\npm-cache\\_logs\\2022-01-04T07_39_31_143Z-debug.log

如何修复RequestError: self signed certificate in certificate chain 错误?

  • 请参阅:troubleshooting 还将C:\\Users\\ducpm34\\AppData\\Local\\npm-cache_logs\\2022-01-04T07_39_31_143Z-debug.log 文件的内容添加到您的问题中

标签: electron


【解决方案1】:

要在 Gokul S 的答案中添加信息,如果您在 Windows 系统上,我发现指定如何更改此变量很有用:

  • 电源外壳:

      $env:NODE_TLS_REJECT_UNAUTHORIZED=0
    
  • 命令

      set NODE_TLS_REJECT_UNAUTHORIZED=0
    

【讨论】:

    【解决方案2】:

    使用此命令 $export NODE_TLS_REJECT_UNAUTHORIZED=0 ,稍后感谢我!

    【讨论】:

    • 您的答案可以通过额外的支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写好答案的信息in the help center
    【解决方案3】:

    我卸载并重新安装了 nodejs,在 npm install 使用命令 $export NODE_TLS_REJECT_UNAUTHORIZED=0 之前,

    【讨论】:

      猜你喜欢
      • 2020-07-24
      • 2019-07-14
      • 2020-01-28
      • 2019-10-31
      • 2020-11-01
      • 2019-05-20
      • 2021-07-27
      • 1970-01-01
      • 2018-08-12
      相关资源
      最近更新 更多