ng serve --open 报告端口 4200 已在使用中,但未使用时 [英] ng serve --open reports port 4200 is already in use when it isn't
问题描述
当我尝试使用命令运行我的 angular 应用程序时
When I try to run my angular app using command
ng serve -o --port 4200
它显示了这样的错误,
端口 4200 已被使用,尝试不同的端口
但是我检查了一下,使用此命令在该端口中没有正在运行的进程
But I checked that, there is no running process in that port using this command
sudo lsof -i -P -n |grep LISTEN
我也尝试过不同的端口,但结果相同,表明该端口也在使用中.
I have also tried different ports but result is same showing that port is also in use.
当我尝试动态端口选择命令 (--port 0) 时,应用程序运行.但我必须指定端口号.
When I tried dynamic port selection command ( --port 0 ) the app runs . But I must have to specify the port number.
我正在使用
节点版本 - 8.12.0
角度版本 - 5.2.6
Angular CLI 版本 - 1.7.1
I am using
Node version - 8.12.0
Angular version - 5.2.6
Angular CLI version - 1.7.1
推荐答案
遇到了同样的问题,这是一个糟糕的 portfinder 版本.在他们修复它之前,直接在 devDependences 中指定:
Had the same problem, it's a bad version of portfinder. Until they fix it, specify directly in devDependences:
"portfinder": "1.0.20",
这篇关于ng serve --open 报告端口 4200 已在使用中,但未使用时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!