36
22

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Proxy環境でElectronインストールしようとしたら隠れた罠があったんです

Last updated at Posted at 2020-02-25

何が起こったか?

会社でElectron使おうと思って、yarn installしたのにバイナリが降ってこなかった。
Quick Startも、Electronのインストールだけできなくて、なんぞこれってなった。
ちなみに家だと、どちらもすんなり動いた。

Proxyじゃん...

家ならセーフ会社でアウトって、完全にProxyのせいじゃん

$ npm -g config set proxy http://proxy:port
$ npm -g config set https-proxy http://proxy:port

Proxy設定は、これまでに行っていたが念の為もう一度設定してみる。

ダメです。
Electronだけインストールできない。
ただnode_modules見に行くと、

.
├── LICENSE
├── README.md
├── cli.js
├── dist ★これがない
├── electron.d.ts
├── index.js
├── install.js
├── node_modules
├── package.json
└── path.txt

こんな感じ
distディレクトリだけない

公式ドキュメント

ちゃんと読んだことなかったけど、Proxyについて書いてくれていた。

If you need to use an HTTP proxy, you need to set the ELECTRON_GET_USE_PROXY variable to any value, plus additional environment variables depending on your host system's Node version:

Node 10 and above
Before Node 10

このELECTRON_GET_USE_PROXYが、やっかい というか使っている例をそんなに見つけられなかった。

しかもyou need to set the ELECTRON_GET_USE_PROXY variable to any value
これ以外に使い方みたいなのが書いてない

使用例ありました

export ELECTRON_GET_USE_PROXY=true // to activate proxy for electron/get module
export GLOBAL_AGENT_HTTPS_PROXY=my_proxy to configure global agent proxy

なるほど
実際使うのはWindows環境だったので

windows
SET ELECTRON_GET_USE_PROXY=true 
SET GLOBAL_AGENT_HTTPS_PROXY=http://proxy:port
Linux
export ELECTRON_GET_USE_PROXY=true
export GLOBAL_AGENT_HTTPS_PROXY=http://proxy:port

としてからインストールするとすんなり入った。

感想

ググるとnpm config set proxyで解決するケースが大半なんで過信してたけど、ELECTRON_GET_USE_PROXYは罠過ぎた。

参考サイト

36
22
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
36
22

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?