美文网首页
vue-cli-3.x在局域网创建项目失败的解决办法

vue-cli-3.x在局域网创建项目失败的解决办法

作者: 喵小鲸2号 | 来源:发表于2018-05-24 15:46 被阅读0次

    在公司内网利用vue-cli-3.x,create项目时,总是提示失败:

    RequestError: Error: connect ETIMEDOUT 151.101.72.162:443
        at new RequestError (C:\Users\vitaxu\AppData\Roaming\npm\node_modules\@vue\cli\node_modules\request-promise-core\lib\errors.js:14:15)
        at Request.plumbing.callback (C:\Users\vitaxu\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\vitaxu\AppData\Roaming\npm\node_modules\@vue\cli\node_modules\request-promise-core\lib\plumbing.js:46:31)
        at self.callback (C:\Users\vitaxu\AppData\Roaming\npm\node_modules\@vue\cli\node_modules\request\request.js:185:22)
        at emitOne (events.js:116:13)
        at Request.emit (events.js:211:7)
        at Request.onRequestError (C:\Users\vitaxu\AppData\Roaming\npm\node_modules\@vue\cli\node_modules\request\request.js:877:8)
        at emitOne (events.js:116:13)
        at ClientRequest.emit (events.js:211:7)
        at TLSSocket.socketErrorListener (_http_client.js:387:9)
    

    解决办法:

    在request.js(路径: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)
      }
    }
    

    参考链接:https://github.com/request/request-promise/issues/255

    相关文章

      网友评论

          本文标题:vue-cli-3.x在局域网创建项目失败的解决办法

          本文链接:https://www.haomeiwen.com/subject/sdesjftx.html