Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/milewski/cross-port-killer
Kill any process running on a given TCP port on Windows, Linux or Mac
https://github.com/milewski/cross-port-killer
cross-platform kill-port linux mac process-kill windows
Last synced: about 6 hours ago
JSON representation
Kill any process running on a given TCP port on Windows, Linux or Mac
- Host: GitHub
- URL: https://github.com/milewski/cross-port-killer
- Owner: milewski
- License: mit
- Created: 2017-04-28T16:22:46.000Z (over 7 years ago)
- Default Branch: development
- Last Pushed: 2024-08-16T05:49:47.000Z (about 1 month ago)
- Last Synced: 2024-09-19T20:32:17.318Z (5 days ago)
- Topics: cross-platform, kill-port, linux, mac, process-kill, windows
- Language: TypeScript
- Homepage:
- Size: 236 KB
- Stars: 48
- Watchers: 1
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# cross-port-killer
[![npm version](https://badge.fury.io/js/cross-port-killer.svg)](https://badge.fury.io/js/cross-port-killer)
[![npm downloads](https://img.shields.io/npm/dm/cross-port-killer.svg)](https://www.npmjs.com/package/cross-port-killer)Kill any process running on a given TCP port on **Windows**, **Linux** or **Mac**
## Install
```bash
$ npm install cross-port-killer -D
```## Usage
```js
import { kill, killer } from 'cross-port-killer';kill(9090).then(pids => {
console.log(pids)
})// you could also kill pids manually if you know them... this would save you bringing up another lib, you are welcome.
killer.killByPid(12345).then(() => console.log('done'))
killer.killByPids([12345, 54321]).then(() => console.log('done'))
```
This lib also comes with a `CLI`.To kill any process occupying the port 9090 you can run:
```bash
$ npx cross-port-killer 9090
```or
```bash
$ npm install cross-port-killer -g
```
```bash
$ kill-port 9090
```## Dependencies
On **Linux**/**Mac** this library depends on `lsof` in case you don't have it installed (perhaps you are using docker?) run:
```bash
$ apt install lsof
```On **Mac**, It comes with the OS by default so nothing to worry.
## License
[MIT](LICENSE) © [Rafael Milewski](https://rafael-milewski.com?github=readme)