x)- [ ] new
- [ ] build
- [x ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc
Unsure
Despite the fact that it's given a free port, ng serve refuses to run on any port, saying "Port XXXX is already in use. Use '--port' to specify a different port." where XXXX is the port number. It's not an issue of the port being in use by another process, because I used the same port number to launch other applications, like React, and those worked fine. It is rejecting any port number I give it with the same error.
I have two angular applications, one works fine, the other does not. Both are in the same directory, but should not be interfering with each other
Directory tree:
udemyangular
--my-first-app
--prnnppr-app
First one won't run, second one does. my-first-app is nothing more than the scaffold from ng new, and prnnppr-app is just a starter project for work with a few custom components, I have otherwise not touched .angular.json, or package.json or any of the other config files. I've also deleted and regenerated my-first-app and got the same result.
Create two angular applications in the same directory, run ng serve in both of them. Theoretically they should both run fine (provided of course they're given different ports.)
Port 3000 is already in use. Use '--port' to specify a different port.
OS: darwin x64
Angular: 6.1.10
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.6.8
@angular-devkit/build-angular 0.6.8
@angular-devkit/build-optimizer 0.6.8
@angular-devkit/core 0.6.8
@angular-devkit/schematics 0.6.8
@angular/cli 6.0.8
@ngtools/webpack 6.0.8
@schematics/angular 0.6.8
@schematics/update 0.6.8
rxjs 6.5.2
typescript 2.7.2
webpack 4.8.3
Anything else relevant?
Other programs, like npm run start for React, run just fine on any given port number, so it's not an issue of the ports being in use by some other process.
Commands like sudo kill $(sudo lsof -t -i:4200) have not helped.
Rebooting the pc did not help.
@jckuhl : this appears to be an issue with the portfinder package (as seen here in #15369).
To fix it, I explicitly downgraded my portfinder by adding "portfinder": "1.0.20" to my devDependencies block (local dev only) in my package.json.
After deleting node_modules, and doing an npm install, all works as intended again (until this is fixed in portfinder).
(Note: I see that the linked stackoverflow solution does the exact same thing)
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
_This action has been performed automatically by a bot._
Most helpful comment
@jckuhl : this appears to be an issue with the
portfinderpackage (as seen here in #15369).To fix it, I explicitly downgraded my portfinder by adding
"portfinder": "1.0.20"to mydevDependenciesblock (local dev only) in mypackage.json.After deleting
node_modules, and doing annpm install, all works as intended again (until this is fixed in portfinder).(Note: I see that the linked stackoverflow solution does the exact same thing)