electron: Behind proxy, installation failed with 7.0.0, but works with 6.1.2

Preflight Checklist

  • I have read the Contributing Guidelines for this project.
  • I agree to follow the Code of Conduct that this project adheres to.
  • I have searched the issue tracker for an issue that matches the one I want to file, without success.

Issue Details

  • Electron Version:
    • 7.0.0
  • Operating System:
    • Windows 10 (1709)
  • Last Known Working Electron version:
    • 6.1.2

Expected Behavior

Successful installation behind proxy.

Actual Behavior

Installation failed.

C:\Users\vmi>npm -g i electron
C:\Program Files\nodejs\electron -> C:\Program Files\nodejs\node_modules\electron\cli.js

> electron@7.0.0 postinstall C:\Program Files\nodejs\node_modules\electron
> node install.js

(node:20112) UnhandledPromiseRejectionWarning: Error: EPERM: operation not permitted, lstat 'C:\Users\vmi\AppData\Local\Temp\electron-download-W5hdD0\electron-v7.0.0-win32-x64.zip'
(node:20112) 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:20112) [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.
+ electron@7.0.0
added 59 packages from 67 contributors in 11.229s

But, successful installation 6.1.2.

C:\Users\vmi>npm -g rm electron
removed 59 packages in 0.803s

C:\Users\vmi>npm -g i electron@6.1.2
C:\Program Files\nodejs\electron -> C:\Program Files\nodejs\node_modules\electron\cli.js

> electron@6.1.2 postinstall C:\Program Files\nodejs\node_modules\electron
> node install.js

Downloading tmp-20364-1-SHASUMS256.txt-6.1.2
[============================================>] 100.0% of 5.15 kB (5.15 kB/s)
+ electron@6.1.2
added 145 packages from 140 contributors and updated 1 package in 244.893s

Additional Information

I set %HOMEDRIVE%%HOMEPATH%\.npmrc as follows:

proxy=http://PROXY_USER:PROXY_PW@PROXY_HOST:8080/
https-proxy=http://PROXY_USER:PROXY_PW@PROXY_HOST:8080/
noproxy=localhost,127.0.0.1,192.168.,10.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 12
  • Comments: 25 (2 by maintainers)

Most upvoted comments

The workaround of specifying environment variables from https://github.com/castlabs/electron-releases/issues/45#issuecomment-549385236 worked for me:

npx cross-env ELECTRON_GET_USE_PROXY=true GLOBAL_AGENT_HTTPS_PROXY=http://localhost:3128 npm install electron

Where http://localhost:3128 is the URL of the proxy I connect through (in this case connecting through cntlm)

If you’ve already installed the electron package but downloading the electron binary failed, you could run:

npx cross-env ELECTRON_GET_USE_PROXY=true GLOBAL_AGENT_HTTPS_PROXY=http://localhost:3128 node node_modules/electron/install

The workaround of specifying environment variables from castlabs/electron-releases#45 (comment) worked for me:

npx cross-env ELECTRON_GET_USE_PROXY=true GLOBAL_AGENT_HTTPS_PROXY=http://localhost:3128 npm install electron

Where http://localhost:3128 is the URL of the proxy I connect through (in this case connecting through cntlm)

If you’ve already installed the electron package but downloading the electron binary failed, you could run:

npx cross-env ELECTRON_GET_USE_PROXY=true GLOBAL_AGENT_HTTPS_PROXY=http://localhost:3128 node node_modules/electron/install

It works for me.

update: it’s fixed now.

change url to:

electron_mirror=https://cdn.npm.taobao.org/dist/electron/

from:

https://github.com/cnpm/cnpmjs.org/issues/1530#issuecomment-561081645

Same kind of problem with 7.0.1 (whether behind a proxy or not), but with a timeout error instead of a permission problem.

electron@7.0.1 postinstall /media/fr_romain/DATA/Sites/ordomatic/node_modules/electron node install.js

(node:10614) UnhandledPromiseRejectionWarning: RequestError: connect ETIMEDOUT 140.82.118.4:443 at ClientRequest.<anonymous> (/media/fr_romain/DATA/Sites/ordomatic/node_modules/got/source/request-as-event-emitter.js:178:14) at Object.onceWrapper (events.js:300:26) at ClientRequest.emit (events.js:215:7) at ClientRequest.origin.emit (/media/fr_romain/DATA/Sites/ordomatic/node_modules/@szmarczak/http-timer/source/index.js:37:11) at TLSSocket.socketErrorListener (_http_client.js:406:9) at TLSSocket.emit (events.js:210:5) at emitErrorNT (internal/streams/destroy.js:92:8) at emitErrorAndCloseNT (internal/streams/destroy.js:60:3) at processTicksAndRejections (internal/process/task_queues.js:80:21) (node:10614) 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:10614) [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 ordomatic@1.0.0 No description npm WARN ordomatic@1.0.0 No repository field.

  • electron@7.0.1 added 86 packages from 90 contributors and audited 104 packages in 182.269s found 0 vulnerabilities

– Edit:

  • I am on Ubuntu 18.04
  • Electron@6.1.3 postinstall works fine.

No, the CDN domain name will be deactivated soon. Use the following settings directly

registry=https://registry.npmmirror.com
ELECTRON_MIRROR=https://npmmirror.com/mirrors/electron/
ELECTRON_CUSTOM_DIR="{{ version }}"
ELECTRON_BUILDER_BINARIES_MIRROR=https://npmmirror.com/mirrors/electron-builder-binaries/

In this way, both the electronic ontology and the builder can be used normally. The only problem is that the Taobao image will fail to synchronize from time to time, and the normal electronic release version may be lost

Still the same with electron@7.1.2 postinstall

> node install.js

(node:9927) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 SIGINT listeners added. Use emitter.setMaxListeners() to increase limit
(node:10024) UnhandledPromiseRejectionWarning: RequestError: connect ETIMEDOUT 140.82.118.3:443
    at ClientRequest.request.once.error (/project/node_modules/got/source/request-as-event-emitter.js:178:14)
    at Object.onceWrapper (events.js:286:20)
    at ClientRequest.emit (events.js:203:15)
    at ClientRequest.origin.emit.args (/project/node_modules/@szmarczak/http-timer/source/index.js:37:11)
    at TLSSocket.socketErrorListener (_http_client.js:392:9)
    at TLSSocket.emit (events.js:198:13)
    at emitErrorNT (internal/streams/destroy.js:91:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:59:3)
    at process._tickCallback (internal/process/next_tick.js:63:19)
(node:10024) 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:10024) [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.

EDIT: meanwhile they released v7.1.3 and my company added 140.82.118.4 and 114.55.80.225 to the whitelist. When it gives ETIMEDOUT it’s a company configuration issue (or at least fixable by the proxy maintainer)

try this

npm_config_electron_mirror="https://npm.taobao.org/mirrors/electron/" npm_config_electron_custom_dir="7.1.0" yarn add electron

from segmentfault.com/a/1190000020890483

so, follow this steps:

npm install -g cross-env
cross-env npm_config_electron_mirror="https://npm.taobao.org/mirrors/electron/" npm_config_electron_custom_dir="7.1.0" npm install electron

it works,but it’s still a temporary solution.

and i think, the reason for this is electron/get simplify the process of url combine,but cause the different url for the dir part

https://github.com/electron/get/blob/49a318111b2838486f7778f27b94d992772b8eb7/src/index.ts#L57

export async function downloadArtifact(
  _artifactDetails: ElectronPlatformArtifactDetailsWithDefaults,
): Promise<string> {
  const artifactDetails: ElectronArtifactDetails = _artifactDetails.isGeneric
    ? {
        ..._artifactDetails,
      }
    : {
        platform: process.platform,
        arch: getHostArch(),
        ..._artifactDetails,
      };
  ensureIsTruthyString(artifactDetails, 'version');
  artifactDetails.version = normalizeVersion(artifactDetails.version);


the artifactDetails.version = normalizeVersion(artifactDetails.version); just add ‘v’ for prefix

then ```function getArtifactRemoteURL`` use this ‘v7.1.0’ for the default custom dir path

https://github.com/electron/get/blob/49a318111b2838486f7778f27b94d992772b8eb7/src/artifact-utils.ts#L47

const path = mirrorVar('customDir', opts, details.version);

@MarshallOfSound

Me,too. The problem is mainly in the @electron/get package

when i use mirror site it seems that @electron/get request the wrong url:

https://npm.taobao.org/mirrors/electron/v7.0.0/electron-v7.0.0-darwin-x64.zip

in 6.1.2

https://npm.taobao.org/mirrors/electron/6.1.2/electron-v6.1.2-darwin-x64.zip

it not strip ‘v’ from version number in the dir part .

so different behavior for electron-download from @electron/get package