# 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.

Stars: 9.5k · Language: TypeScript · License: MIT · Categories: File Management

- Repository: https://github.com/voidcosmos/npkill
- Website: https://npkill.js.org
- Page: https://www.trmn.sh/tools/npkill

## Install

- npx: `npx npkill`
- npm: `npm i -g npkill`

## Overview

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

```bash
# via npx
npx npkill
```

```bash
# via npm
npm i -g npkill
```

![npkill demo GIF](https://media.trmn.sh/cached/b5dcd36592b4fbf27ff2fc0ec82faa86ffde7d4a07410109f35e812cf351d34a.gif)

## Alternatives

- [lf](https://www.trmn.sh/tools/lf.md): Terminal file manager written in Go inspired by ranger with vi-style keybindings and shell integration (Go, 9.6k stars)
- [pdfcpu](https://www.trmn.sh/tools/pdfcpu.md): PDF processing library and CLI written in Go for validating, merging, splitting, encrypting, stamping, signing and extracting content from PDFs. (Go, 8.9k stars)
- [Dufs](https://www.trmn.sh/tools/dufs.md): File server with static serving, uploads, search, zip folder download, account-based access control, HTTPS, and WebDAV, usable from a browser or curl. (Rust, 11.0k stars)
- [dust](https://www.trmn.sh/tools/dust.md): A disk usage analyzer that shows directory sizes with visual bars and intelligent tree traversal (Rust, 12.6k stars)
- [dua](https://www.trmn.sh/tools/dua.md): Disk usage analyzer that provides fast, parallel directory scanning with an optional interactive TUI for file deletion (6.4k stars)

---

Canonical: https://www.trmn.sh/tools/npkill
