Vue-cli: "vue create" failing behind a proxy

Created on 19 Mar 2018  路  17Comments  路  Source: vuejs/vue-cli

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\Roamingnpmnode_modules\@vue\clinode_modules\request-promise-core\lib\errors.js:14:15) at Request.plumbing.callback (C:\Users\tabtis\AppData\Roamingnpmnode_modules\@vue\clinode_modules\request-promise-core\lib\plumbing.js:87:29) at Request.RP$callback [as _callback] (C:\Users\tabtis\AppData\Roamingnpmnode_modules\@vue\clinode_modules\request-promise-core\lib\plumbing.js:46:31) at self.callback (C:\Users\tabtis\AppData\Roamingnpmnode_modules\@vue\clinode_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\Roamingnpmnode_modules\@vue\clinode_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?

Windows now cli

Most helpful comment

@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.

All 17 comments

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: https://github.com/npm/npm/pull/19157

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/"

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

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.

Here's a workaround.
You have to add manually your proxy specification as part of reqOpts in the request.js file (npmnode_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)
  }
}

@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)

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?

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.

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

https://github.com/vuejs/vue-cli/issues/984

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\Roamingnpmnode_modules\@vue\clinode_modules\request\lib#40

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.

i had to do this:

````javascript
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)

}
}

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?

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.

@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.

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

@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?

Was this page helpful?
0 / 5 - 0 ratings