EXPO init project proxy server error

Hi,

Can someone please tell me how to solve the following problem?

I got a download error when I was creating a new project using expo init newProject in Windows 10 command window with Admin right.The computer is behind a proxy server.

I searched the Internet for answer with no luck.

These are the commands I have tried.
set HTTP_PROXY=http://ProxyServerIP:8080 and
netsh winhttp set proxy ProxyServerIP:8080

Any help would be appreciated.

Can someone please answer the question? Many thanks.

Hi @study4ever

You’ll need to set HTTPS_PROXY=http://ProxyServerIP:8080 (note HTTPS) and then in the same terminal window after that run expo init ...

If that doesn’t work, please post the error message you get.

You could also try setting the HTTPS_PROXY environment variable permanently instead of in the terminal. If you do it in the terminal it will only apply to commands you run in that same terminal session.

Hi Wodin,

Thank you. I have tried both set HTTPS_PROXY=http://ProxyServerIP:8080 and set HTTP_PROXY=http://ProxyServerIP:8080. In addition, I have set up the system environment variable.
It still does not work.

Error Output:
C:\test>expo init newPrj
√ Choose a template: » blank a minimal app as clean as an empty canvas
× Something went wrong while downloading and extracting the template.
request to https://registry.npmjs.org/expo-template-blank/-/expo-template-blank-44.0.4.tgz failed, reason: read ECONNRESET
FetchError: request to https://registry.npmjs.org/expo-template-blank/-/expo-template-blank-44.0.4.tgz failed, reason: read ECONNRESET
at ClientRequest. (C:\Users\Student\AppData\Roaming\npm\node_modules\expo-cli\node_modules\node-fetch\lib\index.js:1491:11)
at ClientRequest.emit (node:events:526:28)
at TLSSocket.socketErrorListener (node:_http_client:442:9)
at TLSSocket.emit (node:events:526:28)
at emitErrorNT (node:internal/streams/destroy:157:8)
at emitErrorCloseNT (node:internal/streams/destroy:122:3)
at processTicksAndRejections (node:internal/process/task_queues:83:21)

Just as a test, what does the following give you?

C:\test>npx cross_env=1 https_proxy=http://127.0.0.1:1234 expo whoami

Hi wodin,
Thank you for your reply.

C:\test>npx cross_env=1 https_proxy=http://127.0.0.1:1234 expo whoami
npm ERR! code EINVALIDTAGNAME
npm ERR! Invalid tag name “cross_env=1”: Tags may not have any characters that encodeURIComponent encodes.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Student\AppData\Local\npm-cache_logs\2022-03-25T06_07_33_711Z-debug-0.log

Log file content
0 verbose cli [
0 verbose cli ‘C:\Program Files\nodejs\node.exe’,
0 verbose cli ‘C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js’,
0 verbose cli ‘exec’,
0 verbose cli ‘–’,
0 verbose cli ‘cross_env=1’,
0 verbose cli ‘https_proxy=http://127.0.0.1:1234’,
0 verbose cli ‘expo’,
0 verbose cli ‘whoami’
0 verbose cli ]
1 info using npm@8.5.0
2 info using node@v16.14.2
3 timing npm:load:whichnode Completed in 0ms
4 timing config:load:defaults Completed in 1ms
5 timing config:load:file:C:\Program Files\nodejs\node_modules\npm\npmrc Completed in 3ms
6 timing config:load:builtin Completed in 3ms
7 timing config:load:cli Completed in 2ms
8 timing config:load:env Completed in 0ms
9 timing config:load:file:C:\test.npmrc Completed in 0ms
10 timing config:load:project Completed in 4ms
11 timing config:load:file:C:\Users\Student.npmrc Completed in 0ms
12 timing config:load:user Completed in 1ms
13 timing config:load:file:C:\Users\Student\AppData\Roaming\npm\etc\npmrc Completed in 0ms
14 timing config:load:global Completed in 0ms
15 timing config:load:validate Completed in 2ms
16 timing config:load:credentials Completed in 1ms
17 timing config:load:setEnvs Completed in 1ms
18 timing config:load Completed in 15ms
19 timing npm:load:configload Completed in 15ms
20 timing npm:load:setTitle Completed in 0ms
21 timing config:load:flatten Completed in 2ms
22 timing npm:load:display Completed in 4ms
23 verbose logfile C:\Users\Student\AppData\Local\npm-cache_logs\2022-03-25T06_07_33_711Z-debug-0.log
24 timing npm:load:logFile Completed in 6ms
25 timing npm:load:timers Completed in 0ms
26 timing npm:load:configScope Completed in 0ms
27 timing npm:load Completed in 27ms
28 silly logfile start cleaning logs, removing 2 files
29 timing command:exec Completed in 7ms
30 verbose stack Error: Invalid tag name “cross_env=1”: Tags may not have any characters that encodeURIComponent encodes.
30 verbose stack at invalidTagName (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-package-arg\npa.js:89:15)
30 verbose stack at fromRegistry (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-package-arg\npa.js:343:13)
30 verbose stack at resolve (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-package-arg\npa.js:80:12)
30 verbose stack at npa (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-package-arg\npa.js:48:10)
30 verbose stack at C:\Program Files\nodejs\node_modules\npm\node_modules\libnpmexec\lib\index.js:97:18
30 verbose stack at Array.map ()
30 verbose stack at exec (C:\Program Files\nodejs\node_modules\npm\node_modules\libnpmexec\lib\index.js:96:44)
30 verbose stack at async module.exports (C:\Program Files\nodejs\node_modules\npm\lib\cli.js:66:5)
31 verbose cwd C:\test
32 verbose Windows_NT 10.0.19043
33 verbose argv “C:\Program Files\nodejs\node.exe” “C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js” “exec” “–” “cross_env=1” “https_proxy=http://127.0.0.1:1234” “expo” “whoami”
34 verbose node v16.14.2
35 verbose npm v8.5.0
36 error code EINVALIDTAGNAME
37 error Invalid tag name “cross_env=1”: Tags may not have any characters that encodeURIComponent encodes.
38 verbose exit 1
39 timing npm Completed in 372ms
40 verbose code 1
41 error A complete log of this run can be found in:
41 error C:\Users\Student\AppData\Local\npm-cache_logs\2022-03-25T06_07_33_711Z-debug-0.log

Sorry, what I meant to write was:

C:\test>npx cross-env https_proxy=http://127.0.0.1:1234 expo whoami

I don’t know how I got the =1 part in there :astonished:
Also it’s cross-env rather than cross_env. I probably should not have been typing my reply on my phone.

I expect the command to fail, but I am interested in the error.

Hi Wodin,

Many thanks. These are the error messages.

C:\a>npx cross-env https_proxy=http://127.0.0.1:1234 expo whoami
› Not logged in, run expo login to authenticate

C:\a>npx cross-env https_proxy=http://127.0.0.1:8080 expo login
√ Username/Email Address: … study4ever
√ Password: … ********
connect ECONNREFUSED 127.0.0.1:8080
Error: connect ECONNREFUSED 127.0.0.1:8080
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1157:16)

C:\a>npx cross-env https_proxy=http://ProxyIP:8080 expo login
√ Username/Email Address: … study4ever
√ Password: … ********
socket hang up
Error: socket hang up
at connResetException (node:internal/errors:691:14)
at Socket.socketOnEnd (node:_http_client:466:23)
at Socket.emit (node:events:538:35)
at endReadableNT (node:internal/streams/readable:1345:12)
at processTicksAndRejections (node:internal/process/task_queues:83:21)

OK, so expo is clearly trying to use the proxy. That’s why you get the connection refused error when specifying http://127.0.0.1:8080

So the problem is that expo and your proxy server are not able to understand each other. This could be e.g. because your proxy is expecting the request to be sent via HTTPS, whereas expo and many (most?) other clients would expect to connect to the proxy via HTTP and then send a CONNECT command to the proxy to initiate the HTTPS connection to the destination server.

You might want to talk to whoever administers the proxy to see if they can shed some light on what is going on. Hopefully the proxy server’s logs will tell you what’s going on.