node.js - vue-cli 创建项目的时候出现connect ECONNREFUSED 错误,请问如何解决?
黄舟
黄舟 2017-04-17 15:23:48
0
7
863

我在用vue.js的vue-cli工具创建项目的时候出现了connect ECONNREFUSED 192.30.252.137:443 这个问题。

用的淘宝镜像

PS F:\myWeb\1guanggao\qixi2016> vue init webpack

? Generate project in current directory? Yes
   vue-cli · connect ECONNREFUSED 192.30.252.137:443
connect ETIMEDOUT 192.30.252.137:443

现在出现这个问题,尝试ping这个地址,结果一直超时

各位知道什么原因导致的,怎么解决吗?

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

reply all(7)
Ty80

I went and finally solved it after struggling for so long~~~~

I wonder if your host file has been modified?

Because I changed the host to circumvent the wall, and then used lantern to circumvent the wall. Today I accidentally saw someone saying that it is enough to delete the host-related configuration for bypassing the firewall. I deleted the configuration related to github and it really worked. . . If your host has been modified, you can give it a try!

I don’t know the reason, but I guess it is possible that the host file configuration conflicts with the proxy software configuration?

大家讲道理

Ask this question

刘奇

Written on mobile phone, vue init webpack project-name

PHPzhong

Has the questioner solved this problem? I have the same problem and don’t know how to solve it...

左手右手慢动作

To put it simply, the reason is a proxy setting issue.

Specifically, in vue-cli, use request to query the list of downloadable templates and use download-git-repo to download the corresponding template.

request Module

request does not have a proxy set. You can modify the places where vue-init is used in the vue-list and request files and add the corresponding proxy server settings, such as the vue-init method in checkDistBranch:

function checkDistBranch (template, cb) {
  request({
    proxy: "Your proxy address",
    url: 'https://api.github.com/repos/' + template + '/branches',
    headers: {
      'User-Agent': 'vue-cli'
    }
  }, function (err, res, body) {
    if (err) logger.fatal(err)
    if (res.statusCode !== 200) {
      logger.fatal('Template does not exist: ' + template)
    } else {
      var hasDist = JSON.parse(body).some(function (branch) {
        return branch.name === 'dist'
      })
      return cb(hasDist ? template + '#dist' : template)
    }
  })
}

This ensures that vue-cli can query the corresponding downloadable template list.

download-git-repo Module

The

download module uses download-git-repo, which depends on the download module. The download module uses the caw module, which can read the proxy we set in .npmrc, so when it is set .npmrc There will be no problem in the process of downloading the template.

Solution

If your network environment requires setting up a proxy server to access the external network, then you need:

  • Modify the calling method of request and add the proxy attribute.

  • Set up your .npmrc file and configure the corresponding proxy server.

To be simpler, you can also directly download the corresponding template, such as webpack-simple and place it in the same level directory where vue init needs to be executed, so that vue init can run successfully.

Friendly reminder

Note that the webpack-simple template uses the vue 2.0 version. If you want to develop based on the 1.x version, please use the vue init webpack-simple#1.0 my-project command to specify the template branch.

洪涛

I also encountered the same problem before. After searching for a while, I found that it should be a host problem. I changed my hosts before and restored it to the default state.

左手右手慢动作

Yesterday was good. . After updating to vue-cli version 2.5, I have the same problem as the original po~! ~! ! Ahhhhhhhhhhhhhhhhhhhhhhhh~! ! I don't understand. Find the solution~!

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template