簡體   English   中英

如何解決代理后面的 npm install 期間的連接問題?

[英]How can I solve the connection problem during npm install behind a proxy?

我按照說明操作: https : //www.electronjs.org/docs/tutorial/first-app

我輸入了mkdircdnpm init 他們都工作得很好。 出現了一個名為package.json文件。

然后我輸入npm install --save-dev electron 發生了一些錯誤。

lala@ubu:~/projects/electron/my-app 17:20:34
$ npm install --save-dev electron

> core-js@3.6.4 postinstall /home/lala/projects/electron/my-app/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"

Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!

The project needs your help! Please consider supporting of core-js on Open Collective or Patreon: 
> https://opencollective.com/core-js 
> https://www.patreon.com/zloirock 

Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)


> electron@8.0.0 postinstall /home/lala/projects/electron/my-app/node_modules/electron
> node install.js

(node:5950) UnhandledPromiseRejectionWarning: RequestError: connect ETIMEDOUT 13.250.177.223:443
    at ClientRequest.<anonymous> (/home/lala/projects/electron/my-app/node_modules/got/source/request-as-event-emitter.js:178:14)
    at Object.onceWrapper (events.js:313:26)
    at ClientRequest.emit (events.js:228:7)
    at ClientRequest.origin.emit (/home/lala/projects/electron/my-app/node_modules/@szmarczak/http-timer/source/index.js:37:11)
    at TLSSocket.socketErrorListener (_http_client.js:406:9)
    at TLSSocket.emit (events.js:223:5)
    at emitErrorNT (internal/streams/destroy.js:92:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
    at processTicksAndRejections (internal/process/task_queues.js:81:21)
(node:5950) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:5950) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN my-app@1.0.0 No description
npm WARN my-app@1.0.0 No repository field.

+ electron@8.0.0
added 85 packages from 91 contributors and audited 102 packages in 87.419s

2 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

執行上述指令后,出現一個文件夾node_modules和一個文件package-lock.json

看來我已經成功安裝了依賴項。 但是為什么會出現一個連接錯誤呢?

我無法直接訪問github.com(13.250.177.223) ,但我的代理有效。

我已經按如下方式配置了代理,但連接錯誤仍然存​​在。

我的 ~/.bashrc

export HTTP_PROXY=http://127.0.0.1:8123/
export HTTPS_PROXY=http://127.0.0.1:8123/
export http_proxy=http://127.0.0.1:8123/
export https_proxy=http://127.0.0.1:8123/
$ cat ~/.npmrc 
proxy=http://127.0.0.1:8123/
http-proxy=http://127.0.0.1:8123/
https-proxy=http://127.0.0.1:8123/
noproxy=localhost,127.0.0.1,192.168.,10.
strict-ssl=false

節點 v12.14.1 npm v6.13.7

我怎樣才能減少錯誤?

謝謝你的幫助!

嘗試使用此解決方案從代理后面安裝電子節點模塊。

npx cross-env ELECTRON_GET_USE_PROXY=true GLOBAL_AGENT_HTTPS_PROXY=http://username:password@host:8080 npm install -D electron@latest
  • 如果需要,這里username:password是您的網絡用戶名和密碼。
  • 這里host:8080是您的代理服務器主機名和端口號。
  • cross-env是另一個支持命令行變量的節點模塊(可選)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM