Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"vue create" failing behind a proxy #1009

Closed
stojy opened this issue Mar 19, 2018 · 18 comments
Closed

"vue create" failing behind a proxy #1009

stojy opened this issue Mar 19, 2018 · 18 comments

Comments

@stojy
Copy link

stojy commented Mar 19, 2018

Version

3.0.0-beta.6

Reproduction link

https://github.com/

Steps to reproduce

Create a vue project on a PC behind a firewall.. vue create dummyProject

What is expected?

Prompt for information and then create a webpack project

What is actually happening?

Pauses 5-10s and then returns following error stack..

ERROR RequestError: Error: connect ETIMEDOUT 151.101.104.162:443 RequestError: Error: connect ETIMEDOUT 151.101.104.162:443 at new RequestError (C:\Users\tabtis\AppData\Roaming\npm\node_modules@vue\cli\node_modules\request-promise-core\lib\errors.js:14:15) at Request.plumbing.callback (C:\Users\tabtis\AppData\Roaming\npm\node_modules@vue\cli\node_modules\request-promise-core\lib\plumbing.js:87:29) at Request.RP$callback [as _callback] (C:\Users\tabtis\AppData\Roaming\npm\node_modules@vue\cli\node_modules\request-promise-core\lib\plumbing.js:46:31) at self.callback (C:\Users\tabtis\AppData\Roaming\npm\node_modules@vue\cli\node_modules\request\request.js:186:22) at emitOne (events.js:116:13) at Request.emit (events.js:211:7) at Request.onRequestError (C:\Users\tabtis\AppData\Roaming\npm\node_modules@vue\cli\node_modules\request\request.js:878:8) at emitOne (events.js:116:13) at ClientRequest.emit (events.js:211:7) at TLSSocket.socketErrorListener (_http_client.js:387:9)


Likely related to #785 and #258 (both closed).

I am 99% sure my npm firewall setup is correct since "npm intall" works fine.

If there's no fix, is there a workaround similar to #258 where the template repo can't be cloned and referenced to create a vue-cli v3 styled project?

@wvandeneede
Copy link

wvandeneede commented Mar 23, 2018

I'm getting the same error @vue/[email protected] for vue create testApp

 ERROR  RequestError: Error: connect ETIMEDOUT 151.101.16.162:443
RequestError: Error: connect ETIMEDOUT 151.101.16.162:443
    at new RequestError (C:\Users\me\AppData\Roaming\npm\node_modules\@vue\cli\node_modules\request-promise-core\lib\errors.js:14:15)
    at Request.plumbing.callback (C:\Users\me\AppData\Roaming\npm\node_modules\@vue\cli\node_modules\request-promise-core\lib\plumbing.js:87:29)
    at Request.RP$callback [as _callback] (C:\Users\me\AppData\Roaming\npm\node_modules\@vue\cli\node_modules\request-promise-core\lib\plumbing.js:46:31)
    at self.callback (C:\Users\me\AppData\Roaming\npm\node_modules\@vue\cli\node_modules\request\request.js:186:22)
    at emitOne (events.js:116:13)
    at Request.emit (events.js:211:7)
    at Request.onRequestError (C:\Users\me\AppData\Roaming\npm\node_modules\@vue\cli\node_modules\request\request.js:878:8)
    at emitOne (events.js:116:13)
    at ClientRequest.emit (events.js:211:7)
    at TLSSocket.socketErrorListener (_http_client.js:387:9)

We are behind a proxy and we are using Proget internally to manage our npm packages.
I am running tests with npm 5.8.0-next.0, which allows for a no-proxy setting to be set in npm config.

Does vue-cli take these npm settings into account? We can not use any environment variables as they will interfere with other tools.

The npm config list looks like this:

https-proxy = "http://proxyserver:proxyport/"
no-proxy = "progetserver"
proxy = "http://proxyserver:proxyport/"
registry = "http://progetserver:progetport/npm/"

more info on the no-proxy setting in npm: npm/npm#19157

@pecliu
Copy link

pecliu commented Mar 26, 2018

the same error occurs to me. My cli version is @vue/[email protected]
When enter the command : vue create private-project

 ERROR  RequestError: Error: connect ETIMEDOUT 151.101.228.162:443
RequestError: Error: connect ETIMEDOUT 151.101.228.162:443
    at new RequestError (C:\Users\pecliu\AppData\Roaming\npm\node_modules\@vue\cli\node_modules\request-promise-core\lib\errors.js:14:15)
    at Request.plumbing.callback (C:\Users\pecliu\AppData\Roaming\npm\node_modules\@vue\cli\node_modules\request-promise-core\lib\plumbing.js:87:29)
    at Request.RP$callback [as _callback] (C:\Users\pecliu\AppData\Roaming\npm\node_modules\@vue\cli\node_modules\request-promise-core\lib\plumbing.js:46:31)
    at self.callback (C:\Users\pecliu\AppData\Roaming\npm\node_modules\@vue\cli\node_modules\request\request.js:186:22)
    at emitOne (events.js:116:13)
    at Request.emit (events.js:211:7)
    at Request.onRequestError (C:\Users\pecliu\AppData\Roaming\npm\node_modules\@vue\cli\node_modules\request\request.js:878:8)
    at emitOne (events.js:116:13)
    at ClientRequest.emit (events.js:211:7)
    at TLSSocket.socketErrorListener (_http_client.js:387:9)

My npm intall works fine.
and my npm proxy config is

; userconfig C:\Users\pecliu\.npmrc
https-proxy = "http://proxy.com:8080/"
proxy = "http://proxy.com:8080/"

@ghost
Copy link

ghost commented Mar 29, 2018

Have you tried to set proxy variables with global flag and not on user profile?

npm config set proxy http://proxy.company.com:8080 --global
npm config set https-proxy http://proxy.company.com:8080 --global

@sirberus
Copy link

sirberus commented Mar 30, 2018

Having the same exact problem. Did not experience this just 7 days ago, also w/ cli 3.0. I have configured the proxy and npm itself is fine, it's just vue-cli

Update: uninstalled node, reinstalled, reconfigured proxy (w/ global flag), npm installed, and still the issue persists. Windows 10 and Server 2012 both.

@cyborg29
Copy link

cyborg29 commented Apr 4, 2018

Here's a workaround.
You have to add manually your proxy specification as part of reqOpts in the request.js file (npm\node_modules@vue\cli\lib\util).

const request = require('request-promise-native')

module.exports = {
  async get (uri) {
    const reqOpts = {
      method: 'GET',
      resolveWithFullResponse: true,
      json: true,
      uri,
      proxy: 'http://<your.proxy.info>:8080'    }

    return request(reqOpts)
  }
}

@stojy
Copy link
Author

stojy commented Apr 5, 2018

@stephanerotureau, sorry for the delayed reply (Easter holidays). I have now tried the global proxy setup, but alas it still fails with the same error.

vue create project

ERROR RequestError: Error: connect ETIMEDOUT 151.101.104.162:443 RequestError: Error: connect ETIMEDOUT 151.101.104.162:443 at new RequestError (C:\Users\tabtis\AppData\Roaming\npm\node_modules\@vue\cli\node_modules\request-promise-core\lib\errors.js:14:15) at Request.plumbing.callback (C:\Users\tabtis\AppData\Roaming\npm\node_modules\@vue\cli\node_modules\request-promise-core\lib\plumbing.js:87:29) at Request.RP$callback [as _callback] (C:\Users\tabtis\AppData\Roaming\npm\node_modules\@vue\cli\node_modules\request-promise-core\lib\plumbing.js:46:31) at self.callback (C:\Users\tabtis\AppData\Roaming\npm\node_modules\@vue\cli\node_modules\request\request.js:186:22) at emitOne (events.js:116:13) at Request.emit (events.js:211:7) at Request.onRequestError (C:\Users\tabtis\AppData\Roaming\npm\node_modules\@vue\cli\node_modules\request\request.js:878:8) at emitOne (events.js:116:13) at ClientRequest.emit (events.js:211:7) at TLSSocket.socketErrorListener (_http_client.js:387:9)

@stojy
Copy link
Author

stojy commented Apr 5, 2018

Thanks @cyborg29, your work around works :)

Is there a generic fix that could be applied to utilise the configured npm proxy?

Perhaps using the npm package? I spent a few hours investigating but couldn't work it out. For what it's worth, here's a snippet.

    var npm = require("npm")
    npm.load({}, function() {
      npm.get('proxy')
      })

Or perhaps store the needed (template?) files as an npm package, e.g. vue-cli-templates?

@stojy stojy closed this as completed Apr 5, 2018
@stojy stojy reopened this Apr 5, 2018
@sirberus
Copy link

sirberus commented Apr 5, 2018

Many thanks, @cyborg29. Glad to be up and running again!

It would be nice if the CLI had a flag to pass in a proxy, or a configuration command to set a persistent proxy, or any other built-in solution.

@nxpatterns
Copy link

If you want to hack the cli, there is also an another solution like below:

#984

@snareoj
Copy link

snareoj commented Apr 25, 2018

For me it worked in Powershell like this:

$env:HTTPS_PROXY="http://1.2.3.4:5678"; vue create my-project

Hint was in

AppData\Roaming\npm\node_modules@vue\cli\node_modules\request\lib#40

@pecliu
Copy link

pecliu commented Apr 25, 2018

For me it worked in Powershell like this:
$env:HTTPS_PROXY="http://1.2.3.4:5678"; vue create my-project
Hint was in
AppData\Roaming\npm\node_modules@vue\cli\node_modules\request\lib#40

In my situation, it will cause other problems (like other application's web connetion) if i set system global proxy.

@Ammonix
Copy link

Ammonix commented Apr 27, 2018

i had to do this:

const request = require('request-promise-native')

module.exports = {
  async get(uri) {
    process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'
    const reqOpts = {
      method: 'GET',
      resolveWithFullResponse: true,
      json: true,
      uri,
      proxy: 'http://proxy:123'
    }

    return request(reqOpts)
  }
}

@stojy
Copy link
Author

stojy commented Apr 30, 2018

Thanks @yyx990803 for #b1512be to allow a proxy to specified on the commandline. As a convenience, have you considered using the npm configured proxy as the default proxy for vue-cli so it doesn't need to be specified on every use?

@yyx990803
Copy link
Member

No because it picks up proxy set via environment variables automatically. This is only meant as an escape hatch for those who can't / don't want to use environment variables for whatever reason.

@pecliu
Copy link

pecliu commented Jul 18, 2018

@yyx990803 Thanks!
But how to exactly use -x? The document only said use -x,--proxy
I have tried

vue create -x http://proxy.com my-project

and

vue create -x=http://proxy.com my-project

and

vue create -x my-project http://proxy.com

but none of them worked.

@ericcgu
Copy link

ericcgu commented Apr 18, 2019

Have you tried to set proxy variables with global flag and not on user profile?

npm config set proxy http://proxy.company.com:8080 --global
npm config set https-proxy http://proxy.company.com:8080 --global

you can set http_proxy environment variables but you also have to set proxy for npm. To figure out if this is true, you can try yarn. if it works then you should try the above.

npm config get proxy

@bradykey
Copy link

@yyx990803 Thanks!
But how to exactly use -x? The document only said use -x,--proxy
I have tried

vue create -x http://proxy.com my-project

and

vue create -x=http://proxy.com my-project

and

vue create -x my-project http://proxy.com

but none of them worked.

I cannot find anywhere that references how we are to use a specific proxy with the --proxy flag. Does anybody know?

@saedrna
Copy link

saedrna commented Mar 1, 2021

I don't know why you need a proxy, however if you are like me in China, by setting the following ~/.vuerc may help.

{
  "useTaobaoRegistry": true,
  "packageManager": "yarn"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests