Vue project scaffolding created mandatory use port number 6000 and can not access

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/qq_41359066/article/details/102759458

Make complaints

First Tucao about, the @ vue / cli tool unloading equipment, installed unloading, replace the version installed, and then I thought it was inside npm module management module there is a conflict, delete all, re-initialization. A direct copy of the students @vue module, and then one by one excluded, troubleshoot software problems, thought it was a version of the problem, replace the version: npm install [email protected]
to Baidu, you know almost, csdn, I think I could have searched again, is to modify the default port number, or the default browser war is not like me, a similar problem, really heartbreaking, and I finally found, postman actually be able to access the address 6000 port, QQ browser, IE can be, but I'm competing. Finally out a day I gave up and found QQ browser is also quite fragrant.

Specific issues

vue Tool Version @ vue / cli @ 4.0.0.5 npm version 6.9.0
Here Insert Picture Description
Here Insert Picture Description

  • vue create. By Scaffolding project default after npm run serve the port number should be 8080, but run out of server address is 6000 port, and can not be opened (pictured above) in the browser, the path is in their own node_modules inside (I: D: \ VSCode \ pproject \ node_modules @ vue \ cli-service \ lib \ commands \ serve.js), https: changed ture, the browser can automatically open
  • Here Insert Picture Description
    After allowing the teacher to ask the change (D: \ VSCode \ pproject \ node_modules @ vue \ cli-service \ lib \ options.js) last devServer configuration found is commented out, that npm run serve, not use this code to configure the server.
    I also own middle configured a vue.config.js is to change this configuration, the results did not take effect.

How to solve

I do a day have not been resolved and gave up after a classmate let me change a piece of code is OK, (savior ah !!!!)

Server.js is to change one line of code inside (D: \ VSCode \ pproject \ node_modules @ vue \ cli-service \ lib \ commands \ serve.js) the following:
Here Insert Picture Description
(Ctrl + f) to find this and change it

    portfinder.basePort =defaults.port //更改代码
    // portfinder.basePort = args.port || process.env.PORT || projectDevServerOptions.port || defaults.port //原本代码

This is a statement or, although the default port 8080 is set, but in the final surface, not to use the default port 6000 is set, we will port directly to the foundation he set up as the default 8080,6000 port is limited to the browser All can not be opened.
Anyway, the final end of the story, hoping to help small partners, do not waste time, and finally thanks to students who

Guess you like

Origin blog.csdn.net/qq_41359066/article/details/102759458