Kill-port-process
Cross-platform module to stop one (or more) process(es) running on a port (or a list of ports).
Install
$ npm install kill-port-process
$ yarn add kill-port-process
Usage
Programmatically
const { killPortProcess } = require('kill-port-process');
(async () => {
await killPortProcess(1234);
await killPortProcess([1234, 6789]);
await killPortProcess(1234, { signal: 'SIGTERM' });
})();
Options
signal
(optional): used to determine the command used to kill the provided port(s). Valid values are:
CLI
Install the module globally:
npm install kill-port-process -g
You can use the CLI calling it with kill-port <port>
.
It takes a single port or a list of ports separated by a space. Valid flags are -p
and --port
but are both optional.
$ kill-port 1234
$ kill-port 1234 2345
$ kill-port -p 1234
$ kill-port --port 1234
Flags
--graceful
kill the process gracefully.
- Unix: Sends a
-15
signal to kill (SIGTERM
) rather than -9
(SIGKILL
) - Win: Currently no use