Skip to content

Add --port argument to 'vue serve' command #4342

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

Merged
merged 1 commit into from
Jul 25, 2019
Merged

Add --port argument to 'vue serve' command #4342

merged 1 commit into from
Jul 25, 2019

Conversation

bokub
Copy link
Contributor

@bokub bokub commented Jul 23, 2019

Thanks to webpack, this one line addition in packages/@vue/cli/bin/vue.js is sufficient and works perfectly ! 🎉

image

@haoqunjiang haoqunjiang merged commit 59d3e74 into vuejs:dev Jul 25, 2019
@vue-bot
Copy link

vue-bot commented Jul 25, 2019

Hey @bokub, thank you for your time and effort spent on this PR, contributions like yours help make Vue better for everyone. Cheers! 💚

haoqunjiang pushed a commit that referenced this pull request Aug 2, 2019
@pravosleva
Copy link

--port option does not work.

node 10.16.3
yarn 1.17.3
@vue/cli@3.10.0

image

@pravosleva
Copy link

pravosleva commented Aug 18, 2019

Or vue-cli-service serve --port 3000 in package.json script like this:
image
...But not specified port will be used. Could anybody please help me? )

@bokub
Copy link
Contributor Author

bokub commented Aug 18, 2019

The correct syntax is vue-cli-service serve --port 3000

  • Are you sure the port 3000 is not already used ?
  • Are you sure your dependencies are up to date ? (run npm i again)
  • Do you have @vue/cli version 3.10.0 ?
  • Can you try npm i @vue/cli@4.0.0-beta.1 ?

Also, please don't spam with multiple messages, use the 'edit' button instead

@pravosleva
Copy link

  1. tcp port 3000 was killed in dev.sh before start by $ yarn --cwd ./frontend serve (screen)
  2. All deps installed: $ rm -rf ./node_modules && yarn install in /frontend
  3. Ok. @vue/cli@4.0.0-beta.1 installed globally. But not specified port will be used again.
    image

@bokub
Copy link
Contributor Author

bokub commented Aug 18, 2019

There is a difference between @vue/cli, and @vue/cli-service : https://cli.vuejs.org/guide/#components-of-the-system

Can you try vue serve --port 3000 from your terminal ? (it will use @vue/cli that you installed globally)

@pravosleva
Copy link

pravosleva commented Aug 18, 2019

  1. $ vue serve --port 3000 from terminal:
    image
  2. "@vue/cli-service": "4.0.0-beta.1" added as devDep then $ yarn serve
    image
    ...But not specified port will be used again.

@pravosleva
Copy link

pravosleva commented Aug 18, 2019

@bokub
/frontend directory was created by $ vue create frontend as project with base files pack. In settings i selected yarn to use. So project could be started by $ yarn serve. Is not it so?

@duongle-kdnd
Copy link

I tried to specify port 8080 but it does not work. It always use random port. I took many time to try all ways that i can, but not. Anybody help me to solve this problem.
I wonder why don't Vue-cli use 8080 is default port, and the port number can be changed if anyone need.

@bokub
Copy link
Contributor Author

bokub commented Aug 18, 2019

OK I think I get it.

You're using the command vue-cli-service serve, and this thread is about vue serve, which is completely different. (check out my first screenshot !)

vue-cli-service serve runs the standard web server with HMR. Doc here

vue serve is made for instant prototyping, with just a single *.vue file. Doc here

Conclusion: you're in the wrong thread, and maybe you should create a new issue

I wonder why don't Vue-cli use 8080 is default port

It is, according to this. Maybe this port is already used. Try --port 1234 or whatever other port

@bokub
Copy link
Contributor Author

bokub commented Aug 18, 2019

@bokub
Do you think this issue could be closed successfully? ))

This is not an issue but a Pull Request already merged!
It's about a new feature I've added, not a problem encountered

@bokub
Copy link
Contributor Author

bokub commented Aug 18, 2019

Apparently, someone has the same problem as you 😉
#4452

@duongle-kdnd
Copy link

@bokub As i comment above, can you help me. Why isn't -- port 8080 working to me.

@pravosleva
Copy link

This feature does not work. Unfortunately.
image

@bokub
Copy link
Contributor Author

bokub commented Aug 18, 2019

@pravosleva : My feature has been added to the package @vue/cli, which is used by using the vue command (e.g vue serve).

You have issues on the vue-cli-service command, which is related to the @vue/cli-service package, which is different from the first one.

#4452 is about vue-cli-service serve, and this PR is about vue serve, which works great from my side.
If you have issues on vue-cli-service serve (and you are, according you your screenshots), then I can't help you, and I suggest you reply to #4452 or open a new issue.

@bokub
Copy link
Contributor Author

bokub commented Aug 18, 2019

@duongle-kdnd Can you give any details ?
I cannot help you with so few information

Maybe a new issue might be a good idea if you really think something is not working

@fchangjun
Copy link

The port setting is not in effect because a plug-in that scans for valid ports has recently been updated,
port
So the generated port is not the port we set. You can comment out the scanned code

@fchangjun
Copy link

This plug-in was updated yesterday, so it should be the newly built project that caused this problem.
portfinder

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

Successfully merging this pull request may close these issues.

None yet

6 participants