npm-killer 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +148 -53
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,97 +1,192 @@
|
|
|
1
1
|
# npm-killer
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/npm-killer)
|
|
4
|
+
[](https://www.npmjs.com/package/npm-killer)
|
|
5
|
+
[](https://github.com/afzalbuilds/npm-killer/blob/main/LICENSE)
|
|
6
|
+
[](https://nodejs.org)
|
|
4
7
|
|
|
5
|
-
|
|
8
|
+
> **Interactive CLI tool to find and kill Node.js processes running on ports** — Built for developers who run multiple services and need a visual, interactive way to manage port conflicts.
|
|
6
9
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Why npm-killer?
|
|
13
|
+
|
|
14
|
+
Most port killers (`fuser`, `lsof`, `kill-port`) require you to know the exact PID or port upfront. **npm-killer** is different:
|
|
15
|
+
|
|
16
|
+
- 🎯 **Interactive by default** — Visual checkbox selection, no memorization needed
|
|
17
|
+
- 🔍 **Smart detection** — Finds Node.js, npm, yarn, pnpm, bun, Next.js processes automatically
|
|
18
|
+
- 📋 **Clean table output** — See all processes with ports at a glance
|
|
19
|
+
- ⚡ **Flexible modes** — Interactive, list, single-port, or kill-all
|
|
20
|
+
- 🛡️ **Safe by default** — Confirmation prompts prevent accidental kills
|
|
21
|
+
- 🎨 **Developer-friendly** — Color-coded, readable output
|
|
22
|
+
|
|
23
|
+
---
|
|
13
24
|
|
|
14
25
|
## Installation
|
|
15
26
|
|
|
16
27
|
```bash
|
|
28
|
+
# Global install (recommended)
|
|
17
29
|
npm install -g npm-killer
|
|
18
|
-
```
|
|
19
30
|
|
|
20
|
-
Or use
|
|
21
|
-
```bash
|
|
31
|
+
# Or use without installing
|
|
22
32
|
npx npm-killer
|
|
23
33
|
```
|
|
24
34
|
|
|
25
|
-
|
|
35
|
+
**Requirements:** Node.js 18+, macOS / Linux / Windows (WSL)
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Quick Start
|
|
26
40
|
|
|
27
|
-
### Interactive Mode (Default)
|
|
28
41
|
```bash
|
|
42
|
+
# Interactive mode — select processes with spacebar, press Enter to kill
|
|
29
43
|
npm-killer
|
|
30
|
-
```
|
|
31
|
-
Shows a checklist of all Node.js processes with open ports. Select multiple processes with spacebar, press Enter to confirm.
|
|
32
44
|
|
|
33
|
-
|
|
34
|
-
```bash
|
|
35
|
-
npm-killer --list
|
|
36
|
-
# or
|
|
45
|
+
# List all Node.js processes with ports
|
|
37
46
|
npm-killer -l
|
|
38
|
-
```
|
|
39
47
|
|
|
40
|
-
|
|
41
|
-
```bash
|
|
42
|
-
npm-killer --port 3000
|
|
43
|
-
# or
|
|
48
|
+
# Kill process on specific port (with confirmation)
|
|
44
49
|
npm-killer -p 3000
|
|
45
|
-
```
|
|
46
50
|
|
|
47
|
-
|
|
48
|
-
```bash
|
|
49
|
-
npm-killer --all
|
|
50
|
-
# or
|
|
51
|
-
npm-killer -a
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
### Force Kill (No Confirmation)
|
|
55
|
-
```bash
|
|
56
|
-
npm-killer --port 3000 --force
|
|
51
|
+
# Force kill on port (no confirmation)
|
|
57
52
|
npm-killer -p 3000 -f
|
|
58
53
|
|
|
59
|
-
|
|
54
|
+
# Kill all Node.js processes (with confirmation)
|
|
55
|
+
npm-killer -a
|
|
56
|
+
|
|
57
|
+
# Force kill all
|
|
60
58
|
npm-killer -a -f
|
|
61
59
|
```
|
|
62
60
|
|
|
63
|
-
|
|
61
|
+
---
|
|
64
62
|
|
|
65
|
-
|
|
63
|
+
## Commands Reference
|
|
64
|
+
|
|
65
|
+
| Command | Alias | Description |
|
|
66
|
+
|---------|-------|-------------|
|
|
67
|
+
| `npm-killer` | | Interactive mode (default) |
|
|
68
|
+
| `npm-killer --list` | `-l` | List all Node.js processes with ports in a table |
|
|
69
|
+
| `npm-killer --port <port>` | `-p <port>` | Kill process on specific port |
|
|
70
|
+
| `npm-killer --all` | `-a` | Kill all detected Node.js processes |
|
|
71
|
+
| `npm-killer --force` | `-f` | Skip confirmation prompts |
|
|
72
|
+
| `npm-killer --version` | `-V` | Show version |
|
|
73
|
+
| `npm-killer --help` | `-h` | Show help |
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## Output Examples
|
|
78
|
+
|
|
79
|
+
### Interactive Mode (Default)
|
|
80
|
+
```bash
|
|
66
81
|
$ npm-killer
|
|
67
82
|
|
|
68
83
|
Select processes to kill:
|
|
69
84
|
|
|
70
|
-
✓ 1. node
|
|
71
|
-
✓ 2.
|
|
72
|
-
|
|
85
|
+
✓ 1. node 32724 3001 node /path/to/server.ts
|
|
86
|
+
✓ 2. next-server (v14.2.35) 48706 3000 next-server (v14.2.35)
|
|
87
|
+
─────────────────────────────────────────────────────────────
|
|
73
88
|
◯ Kill ALL Node.js processes
|
|
74
89
|
◯ Exit without killing
|
|
75
90
|
|
|
76
91
|
Kill 2 process(es)? (y/N) y
|
|
77
92
|
|
|
78
|
-
✓ Killed node (PID:
|
|
79
|
-
✓ Killed
|
|
93
|
+
✓ Killed node (PID: 32724)
|
|
94
|
+
✓ Killed next-server (v14.2.35) (PID: 48706)
|
|
80
95
|
```
|
|
81
96
|
|
|
82
|
-
|
|
97
|
+
### List Mode (`-l`)
|
|
98
|
+
```bash
|
|
99
|
+
$ npm-killer -l
|
|
100
|
+
|
|
101
|
+
Node.js Processes with Open Ports:
|
|
102
|
+
|
|
103
|
+
# Name PID Ports Command
|
|
104
|
+
─── ────────────────────── ───── ───── ───────
|
|
105
|
+
1 Code Helper (Plugin) 30509 62481 /Applications/VS Code/...
|
|
106
|
+
2 node 32724 3001 node /project/server.ts
|
|
107
|
+
3 next-server (v14.2.35) 48706 3000 next-server (v14.2.35)
|
|
108
|
+
4 next-server (v16.1.1) 33053 3002 next-server (v16.1.1)
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## Detected Process Types
|
|
114
|
+
|
|
115
|
+
npm-killer automatically detects and lists:
|
|
116
|
+
|
|
117
|
+
- **Node.js** — `node`, `node.js`
|
|
118
|
+
- **Package managers** — `npm`, `yarn`, `pnpm`, `bun`
|
|
119
|
+
- **Frameworks** — `next-server` (Next.js), `nuxt`, `vite`, `webpack-dev-server`
|
|
120
|
+
- **TypeScript runners** — `ts-node`, `tsx`, `nodemon`
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
## Use Cases
|
|
125
|
+
|
|
126
|
+
- **Microservices development** — Multiple services on different ports
|
|
127
|
+
- **Frontend + backend** — Next.js (3000), API (3001), WebSocket (3002)
|
|
128
|
+
- **CI/CD pipelines** — Clean up stray processes before deployments
|
|
129
|
+
- **Port conflicts** — Quickly identify and resolve `EADDRINUSE` errors
|
|
130
|
+
- **Team onboarding** — New developers can see running services instantly
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## How It Works
|
|
135
|
+
|
|
136
|
+
1. Uses `ps-list` to enumerate all running processes
|
|
137
|
+
2. Filters for Node.js-related processes by name and command
|
|
138
|
+
3. Uses `lsof` to detect listening TCP ports per PID
|
|
139
|
+
4. Presents an interactive UI via `inquirer` or formatted table output
|
|
140
|
+
5. Sends `SIGTERM` → `SIGKILL` for graceful then forced termination
|
|
141
|
+
|
|
142
|
+
---
|
|
83
143
|
|
|
84
|
-
|
|
85
|
-
- Run multiple Node.js services and forget which is on which port
|
|
86
|
-
- Want a visual overview before killing anything
|
|
87
|
-
- Prefer interactive selection over memorizing commands
|
|
88
|
-
- Work with npm, yarn, pnpm, bun - all detected automatically
|
|
144
|
+
## Contributing
|
|
89
145
|
|
|
90
|
-
|
|
146
|
+
Contributions are welcome! Please read our [contributing guidelines](CONTRIBUTING.md) first.
|
|
91
147
|
|
|
92
|
-
|
|
93
|
-
|
|
148
|
+
```bash
|
|
149
|
+
# Clone and install
|
|
150
|
+
git clone https://github.com/afzalbuilds/npm-killer.git
|
|
151
|
+
cd npm-killer
|
|
152
|
+
npm install
|
|
153
|
+
|
|
154
|
+
# Run tests
|
|
155
|
+
npm test
|
|
156
|
+
|
|
157
|
+
# Build / test locally
|
|
158
|
+
npm pack
|
|
159
|
+
npm install -g ./npm-killer-*.tgz
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
## Author
|
|
165
|
+
|
|
166
|
+
**Muhammad Afzal** — Full-stack Developer & Open Source Enthusiast
|
|
167
|
+
|
|
168
|
+
- 🐦 **X (Twitter):** [@AfzalBuilds](https://x.com/AfzalBuilds)
|
|
169
|
+
- 🐙 **GitHub:** [afzalbuilds](https://github.com/afzalbuilds)
|
|
170
|
+
- 💼 **LinkedIn:** [afzalbuilds](https://www.linkedin.com/in/afzalbuilds/)
|
|
171
|
+
- 📺 **YouTube:** [@AfzalBuilds](https://www.youtube.com/@AfzalBuilds)
|
|
172
|
+
- 📘 **Facebook:** [AfzalBuilds](https://www.facebook.com/AfzalBuilds)
|
|
173
|
+
|
|
174
|
+
---
|
|
94
175
|
|
|
95
176
|
## License
|
|
96
177
|
|
|
97
|
-
MIT
|
|
178
|
+
MIT License — see [LICENSE](LICENSE) for details.
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## Related Tools
|
|
183
|
+
|
|
184
|
+
- [`kill-port`](https://www.npmjs.com/package/kill-port) — Simple port killer
|
|
185
|
+
- [`fkill-cli`](https://github.com/sindresorhus/fkill-cli) — Cross-platform process killer
|
|
186
|
+
- [`lsof`](https://man7.org/linux/man-pages/man8/lsof.8.html) — List open files (system tool)
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
**Made with ❤️ for developers who hate port conflicts.**
|
|
191
|
+
|
|
192
|
+
*Star this repo if it saved you time!* ⭐
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "npm-killer",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Interactive CLI tool to kill Node.js processes on ports",
|
|
5
5
|
"main": "bin/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -32,4 +32,4 @@
|
|
|
32
32
|
"node": ">=18.0.0"
|
|
33
33
|
},
|
|
34
34
|
"type": "module"
|
|
35
|
-
}
|
|
35
|
+
}
|