p:: Node, CLI f:: npm, pnpm

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 size

Optional global install via npm:

npm i -g npkill

Unix may need sudo for the global install. Scan starts at the current directory unless you pass -d or -f.

Usage

KeyAction
↓ ↑ / j kMove between results
Space / DelDelete the selected folder
oOpen the parent directory
/Regex search (filter results)
TMulti-select mode
VRange select (in multi-select)
ASelect/unselect all (in multi-select)
EnterDelete all selected (in multi-select)
Q / Ctrl+CQuit

⚠️ 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

FlagDescription
-d, --directoryStart search here (default: .)
-f, --fullSearch from the user’s home directory
-t, --targetsComma-separated dir names, e.g. node_modules,.cache
-p, --profilesTarget profile (node by default); lists available if omitted
--configCustom .npkillrc (else ./.npkillrc then ~/.npkillrc)
-E, --excludeComma-separated dirs to skip, quoted: "ignore1, ignore2"
-x, --exclude-sensitiveSkip sensitive directories
-D, --delete-allDelete every match (pair with -x; -y skips the warning)
--dry-runSimulate deletes, nothing is removed
-s, --sortsize, path, or age
--size-unitauto, mb, or gb
--jsonOne JSON object at end of scan
--json-streamOne JSON object per line as results are found
-e, --hide-errorsHide errors
-nu, --no-check-updateSkip 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