Interactive CLI that lists node_modules (and other target dirs) with disk size and last-modified, then lets you delete selected folders from a TUI. TypeScript, MIT, by Nya GarcĂa Gallardo and Juan Torres GĂłmez. Requires Node 14+; on older Node use [email protected].
Install
No install required:
npx npkill -s sizeOptional global install via npm:
npm i -g npkillUnix may need sudo for the global install. Scan starts at the current directory unless you pass -d or -f.
Usage
| Key | Action |
|---|---|
↓ ↑ / j k | Move between results |
| Space / Del | Delete the selected folder |
o | Open the parent directory |
/ | Regex search (filter results) |
T | Multi-select mode |
V | Range select (in multi-select) |
A | Select/unselect all (in multi-select) |
| Enter | Delete all selected (in multi-select) |
Q / Ctrl+C | Quit |
⚠️ Some apps need their node_modules to run. npkill highlights those with a warning. Prefer --dry-run or -x (--exclude-sensitive) before a bulk delete.
Flags
| Flag | Description |
|---|---|
-d, --directory | Start search here (default: .) |
-f, --full | Search from the user’s home directory |
-t, --targets | Comma-separated dir names, e.g. node_modules,.cache |
-p, --profiles | Target profile (node by default); lists available if omitted |
--config | Custom .npkillrc (else ./.npkillrc then ~/.npkillrc) |
-E, --exclude | Comma-separated dirs to skip, quoted: "ignore1, ignore2" |
-x, --exclude-sensitive | Skip sensitive directories |
-D, --delete-all | Delete every match (pair with -x; -y skips the warning) |
--dry-run | Simulate deletes, nothing is removed |
-s, --sort | size, path, or age |
--size-unit | auto, mb, or gb |
--json | One JSON object at end of scan |
--json-stream | One JSON object per line as results are found |
-e, --hide-errors | Hide errors |
-nu, --no-check-update | Skip update check |
Examples
npkill -d ~/projects
npkill -d ~/backups/ --delete-all
npkill -d ~/projects --exclude "progress, ignore-this"
npkill --json > results.json
npkill --json-stream | jq '.result.path'--json / --json-stream are for scripting; there is also a Node API for embedding npkill in scripts.
Gotchas
- CLI can freeze while a folder is deleting
- Size calculations can come out higher than they should
- Sorting (especially by path) slows down when there are many results