npkill
Interactive TUI that scans for node_modules directories, shows their size and last modification, and lets you delete selected ones to free disk space.
npkill is a terminal tool that scans the filesystem for node_modules directories and lists them with the space each one occupies. From the list you pick which directories to delete. A last_mod column shows when a file in the workspace was last modified, which helps identify stale projects. Scanning starts from the current directory by default, or from a path given with -d, or from the user's home with -f.
Navigation uses the arrow keys or j/k. Space or Del deletes the selected folder, and o opens its location. Pressing / enters a regex search mode that filters results, and T toggles multi-select mode, where Space marks items, V selects a range, A toggles all, and Enter deletes the selection. npkill marks directories that installed applications may depend on with a warning symbol. Options cover profiles (-p) and custom targets (-t, for example node_modules,.cache), excludes (-E), sorting by size, path or age (-s), a size unit setting, and a .npkillrc config file.
For automation, --delete-all (-D) removes everything found, and is recommended together with -x to skip sensitive directories. --dry-run simulates deletion without removing anything. --json prints results at the end of the scan, and --json-stream prints one JSON object per line as results are found, which can be piped to tools like jq. A Node API is also available for use in scripts. The search is implemented at a low level for speed, and the tool requires Node 14 or later. It suits JavaScript and TypeScript developers who want to reclaim disk space from accumulated project dependencies.
Installation
# via npx
npx npkill
# via npm
npm i -g npkill

Alternatives & related tools
lf
Terminal file manager written in Go inspired by ranger with vi-style keybindings and shell integration
pdfcpu
PDF processing library and CLI written in Go for validating, merging, splitting, encrypting, stamping, signing and extracting content from PDFs.
Dufs
File server with static serving, uploads, search, zip folder download, account-based access control, HTTPS, and WebDAV, usable from a browser or curl.
dust
A disk usage analyzer that shows directory sizes with visual bars and intelligent tree traversal
dua
Disk usage analyzer that provides fast, parallel directory scanning with an optional interactive TUI for file deletion
add a badge to your README
Maintain npkill? Show that it's featured on trmn. The badge links back to this page.
[](https://www.trmn.sh/tools/npkill?utm_source=badge)<a href="https://www.trmn.sh/tools/npkill?utm_source=badge"><img src="https://www.trmn.sh/badge/npkill.svg" alt="Featured on trmn" height="20"></a>