electron / electron

:electron: Build cross-platform desktop apps with JavaScript, HTML, and CSS
https://electronjs.org
MIT License
114.41k stars 15.44k forks source link

Behind proxy, installation failed with 7.0.0, but works with 6.1.2 #20739

Closed vmi closed 3 years ago

vmi commented 5 years ago

Preflight Checklist

Issue Details

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.
ChasLui commented 5 years ago

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

Xciyang commented 5 years ago

It happened to me, too.

MHTaleb commented 5 years ago

for me the install is working fine under ubuntu 18.0.4 LTS

my npm version is npm@6.12.0 my node version is node@v12.11.0

may be this will help you

freedxz commented 5 years ago

Me too

evn: MacOS 10.15

patrick@PatrickdeMacBook-Pro casher % npm install electron
electron@7.0.0 postinstall /Users/patrick/code/casher/node_modules/electron node install.js

... and blocked

umbrella22 commented 5 years ago

This is also the case in Windows 10 1903. Even with administrator privileges, the installation cannot succeed.

nickfan commented 5 years ago

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

MarshallOfSound commented 5 years ago

@nickfan If there is a bug in Electron Get PRs are more than welcome: https://github.com/electron/get

It has a solid test suite so it should be clear where things go and if they work or not 👍

umbrella22 commented 5 years ago

emm,I successfully installed 7.0.0 by replacing the dependency in install.js and package.json in the electronic package. It seems that Taobao doesn't want to cooperate with the changes or other problems. For the time being, we can use the latest version like this. I hope that the author can make some judgments based on China and thank you very much.

BrRoman commented 5 years ago

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. (/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:

youyinnn commented 5 years ago

same issues

buptUnixGuys commented 5 years ago

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

I think the key point of the problem is that when running postinstall, something went wrong. i try to reproduce the problem with "node install.js" in the node_modules directory of electron.

i just manually run "node install.js" in node_modules/electron directory then everything goes ok.

Tomyail commented 5 years ago

try this

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

from https://segmentfault.com/a/1190000020890483

nickfan commented 5 years ago

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

yunmin97 commented 5 years ago

same error like this: (node:21640) UnhandledPromiseRejectionWarning: Error: EPERM: operation not permitted, lstat 'C:\Users\ADMINI~1\AppData\Local\Temp\electron-download-tfppVA\electron-v7.1.1-win32-x64.zip'

badB00l commented 4 years ago

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)

nickfan commented 4 years ago

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

portenez commented 4 years ago

Same here. Version 6x works, version 7x works.

tjx666 commented 4 years ago

update: it's fixed now.

change url to:

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

from:

cnpm/cnpmjs.org#1530 (comment)

It works!

bradchristensen commented 4 years ago

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
nick318 commented 4 years ago

To hide details of installation, you can add following into your package.json

"scripts": {
    "preinstall": "npm run install-electron",
    "install-electron": "cross-env ELECTRON_GET_USE_PROXY=true GLOBAL_AGENT_HTTPS_PROXY=http://your_proxy npm install electron"
  },
lionkunonly commented 4 years ago

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.

electron-triage commented 3 years ago

The Electron version reported on this issue is no longer supported. See our supported versions documentation.

If this is still reproducible on a supported version, please open a new issue with any other new information that a maintainer should know.

Thank you for taking the time to report this issue and helping to make Electron better! Your help is appreciated.

Zhuzhenghao commented 2 years ago

update: it's fixed now.

change url to:

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

from:

cnpm/cnpmjs.org#1530 (comment)

It works for me.

umbrella22 commented 2 years ago

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

temberature commented 2 years ago

work for me

npm config rm proxy npm config rm https-proxy

https://stackoverflow.com/questions/47885108/unable-to-install-electron-from-npm

paprika135 commented 3 weeks ago

work for me

npm config rm proxy npm config rm https-proxy

https://stackoverflow.com/questions/47885108/unable-to-install-electron-from-npm

thank you so much!!!