npkill is a command-line tool that scans your system for node_modules directories, displays their size, and lets you selectively delete them to reclaim disk space.
The tool solves the problem of node_modules folders consuming significant storage across multiple projects. It works by recursively searching the filesystem for node_modules directories starting from the current working directory, calculating their disk usage, and presenting them in an interactive terminal interface. Users navigate the list with arrow keys or vim-style navigation, mark directories for deletion with the Space or Del key, and execute removals. The tool performs searches at a low level to maintain speed despite potentially scanning many directories.
npkill suits developers who manage multiple Node.js projects and want a quick way to identify and remove unused or old node_modules folders without manual filesystem exploration. It is particularly useful for reclaiming space on machines with many abandoned or inactive projects. The tool includes a safety feature that warns users when a node_modules directory belongs to a system-installed application that may depend on it. Beyond basic deletion, the tool tracks the last modification time of files within each workspace, helping users identify which projects have been inactive. It also supports a search mode using regular expressions to filter results by path, and can output results in JSON format for programmatic use.
The project maintains active development with regular updates and accepts community contributions. The codebase is written in TypeScript and deliberately keeps dependencies minimal to reduce the tool's footprint. The tool is distributed via npm and can be run without installation using npx, making it accessible to developers who want to try it without commitment.