我们在用命令ng serve --port 时经常遇到错误消息:
ubuntu@ip-172-31-12-185:-/KOI/Template/front-end$ ng serve --port 3000Port 3000 is already in use. Use '--port' to specify a different port.Error: Port 3000 is already in use. Use '--port' to specify a different port.at Server. server.once (/home/ubuntu/KOI/Template/front-end/node_modules/@angular-devkit/build-angular/srcngular-cli-files/utilities/check-port.js:27:28)
at object. onceWrapper (events.js:315:30)
at emitone (events.js:116:13)
at server. emit (events.js:211:7)
at emitErrorNT (net.js: 1387:8)
at _combinedTickCallback (internal/process/next_tick.js: 138:11)at process._tickcallback (internal/process/next_tick.js: 180:9)
如何查到哪一个进程占用了端口3000?
![a7bdd52ffa466033ca0e197829a3cc46.png](https://i-blog.csdnimg.cn/blog_migrate/0937d5cdee924502c46de0c2b08d3eb4.jpeg)
命令netstat -tulpn,发现是进程 15089占用了3000.
![713387dab64268aad031d717af68f0d8.png](https://i-blog.csdnimg.cn/blog_migrate/a6d623e861a621202950a59fb8f7402c.jpeg)
再使用ps -aux就能找到该进程的路径了。