killit
Version:
Simple, fast port killer with zero dependencies
135 lines (89 loc) • 2.54 kB
Markdown
# killit
> Simple, fast port killer with **zero dependencies**
Kill processes running on specified ports. Works on macOS, Linux, and Windows.
## Features
- ✨ **Zero dependencies** - Only uses Node.js built-in modules
- 🚀 **Fast & Simple** - Clean TypeScript code
- 🔧 **Cross-platform** - Works on macOS, Linux, and Windows
- 📦 **Tiny** - Minimal footprint
- 🎯 **Multiple ports** - Kill multiple ports at once
- 🔌 **TCP & UDP** - Support for both protocols
## Installation
### Global Installation
```bash
npm install -g killit
```
### Local Installation
```bash
npm install killit
```
### Use without installation (npx)
```bash
npx killit 3000
```
## CLI Usage
```bash
# Kill single port
killit 3000
# Kill multiple ports
killit 3000 8080 5000
# Using --port flag
killit --port 3000
killit --port 3000,8080,5000
# Kill UDP process
killit 9000 --method udp
# Verbose output
killit 3000 --verbose
```
### Options
- `-p, --port <port>` - Port number(s) to kill (comma-separated)
- `-m, --method <protocol>` - Protocol: `tcp` or `udp` (default: `tcp`)
- `-v, --verbose` - Show detailed output
- `-h, --help` - Show help message
## Programmatic Usage
```typescript
import { killPort, killPorts } from 'killit';
// Kill single port
await killPort(3000);
// Kill with options
await killPort(3000, { protocol: 'tcp', verbose: true });
// Kill multiple ports
await killPorts([3000, 8080, 5000]);
// Kill multiple ports with options
await killPorts([3000, 8080], { protocol: 'udp', verbose: true });
```
## API
### `killPort(port, options?)`
Kill process on a single port.
**Parameters:**
- `port` (number | string) - Port number (1-65535)
- `options` (optional)
- `protocol` ('tcp' | 'udp') - Default: 'tcp'
- `verbose` (boolean) - Default: false
**Returns:** Promise<void>
**Throws:** Error if port is invalid or no process found
### `killPorts(ports, options?)`
Kill processes on multiple ports.
**Parameters:**
- `ports` (Array<number | string>) - Array of port numbers
- `options` (optional) - Same as killPort
**Returns:** Promise<void>
**Throws:** Error if any port fails to kill
## Development
```bash
# Install dependencies
npm install
# Build
npm run build
# Watch mode
npm run dev
```
## Why killit?
Compared to other port-killing tools:
- **Zero dependencies** - No external packages needed
- **Simpler code** - Easy to understand and modify
- **TypeScript** - Full type safety
- **Modern** - Uses async/await, ES modules
- **Tiny** - Minimal package size
## License
MIT