问题
When I specify no port or set the port explicitly, I always see:
ember serve --port 4207
Port 4207 is already in use.
It doesn't seem to matter which port I pick.
When I start with port 0 (let the cli pick an available port) it starts on on something around 30000~40000.
I am on a Mac. I just upgraded my ember-cli to 3.12.0
Also: If I start another ember app I have locally, it will run on port 4200. But then I stop it and start the above app and it won't start on that port.
What is wrong here?
回答1:
portfinder, which is a subdependency of Ember CLI, released a new version 1.0.22 a few hours ago (August 17, 2019). That one breaks ember serve. You will see a port in use error for all ports.
If you are unsure which version of portfinder is used in your project, you could run yarn why portfinder or npm list | grep portfinder.
Update: portfinder@1.0.23 was released today (August, 19 2019). It rolls back to 1.0.21 and therefore fixes the issue. You should upgrade to that new release.
The following work-a-rounds are outdated by new release of portfinder.
There are two work-a-round known so far:
1. Downgrading portfinder to 1.0.21.
You could use yarn's resolutions feature to do so. Add this to your package.json:
"resolutions": {
"ember-cli/portfinder": "1.0.21"
}
Don't forget to run yarn install afterwards.
If using npm, you could enforce installing dependencies released before today using the --before option: npm install --before 2019-08-16
2. Using ember serve --port 0
You could start ember serve with --port 0 argument. In that case portfinder picks up a random port. This seems to work. The port used is reported in terminal, e.g.
Build successful (1911ms) – Serving on http://localhost:18780/
The bug is reported here. Hopefully it will be resolved soon.
来源:https://stackoverflow.com/questions/57535688/ember-serve-every-port-is-in-use