首页 > 解决方案 > 端口 4200 已在使用中。使用“--port”指定不同的端口

问题描述

尝试运行时ng serve出现以下错误:

Port 4200 is already in use. Use '--port' to specify a different port.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! product@0.0.0 start: `ng serve --host 0.0.0.0 --disable-host-check`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the product@0.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Mohammad Ajo\AppData\Roaming\npm-cache\_logs\2019-08-18T18_19_41_366Z-debug.log

我已经检查了端口是否被另一个连接保留,并尝试多次更改端口,但始终收到相同的错误。

标签: npmangular-cli

解决方案


对于 Linux 用户:- 这个对我有用

kill -9 $(lsof -t -i:4200)

推荐阅读