kill-port-process

Easily kill hanging processes on ports - on any platform!

Usage no npm install needed!

<script type="module">
  import killPortProcess from 'https://cdn.skypack.dev/kill-port-process';
</script>

README

Kill-port-process

npm version Build Status

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 -E
# or
$ yarn add kill-port-process

Usage

Programmatically

const { killPortProcessĀ } = require('kill-port-process');

const PORT = 1234; // long-running process running on this, e.g. a http-server.

(async () => {
   await killPortProcess(PORT); // takes a number, number[], string or string[]
})();

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
# or multiple ports, separated by space(s)
$ kill-port 1234 2345
# or
$ kill-port -p 1234
# or
$ kill-port --port 1234