npkill logo

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.

install

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

npkill demo GIF

Alternatives & related tools

add a badge to your README

Maintain npkill? Show that it's featured on trmn. The badge links back to this page.

Featured on trmn
Markdown
[![Featured on trmn](https://www.trmn.sh/badge/npkill.svg)](https://www.trmn.sh/tools/npkill?utm_source=badge)
HTML
<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>