stale-modules
v0.2.5
Published
Interactive CLI that finds node_modules folders in projects you haven't touched in a while and lets you reclaim disk space
Maintainers
Readme
stale-modules
Find node_modules folders in projects you haven't touched in a while, and reclaim the disk space — through a fast, friendly interactive CLI.
Works on macOS, Linux, and Windows.
Old side-projects quietly hoard gigabytes in node_modules. stale-modules scans a folder full of projects, finds the ones you haven't worked on in a while, shows you how much space each is wasting, and lets you delete the node_modules with a single confirmation. Your source code is never touched — a quick npm install brings any project back to life.
Quick start
No install needed:
npx stale-modulesThen just answer the prompts.
Usage
npx stale-modules # asks which folder to scan
npx stale-modules --base ~/code # scan ~/code directly, skip the folder questionWhat happens
- Which folder? — point it at the directory that holds your projects (e.g.
~/code). - How many days of inactivity = "stale"? — e.g.
30. Projects untouched for at least that long show up. - Pick what to delete — a checklist of stale projects, each with its
node_modulessize and how long it's been idle, biggest first. - Confirm — nothing is deleted until you explicitly say yes.
Keyboard controls
Every screen shows its controls, but for reference:
| Key | Action |
| --- | --- |
| ↑ / ↓ | Move up / down the list |
| Space | Select / deselect the highlighted project |
| a | Select / deselect all |
| Enter | Confirm and continue |
| Esc | Cancel and quit (nothing is deleted) |
Flags
--base <path>— skip the folder prompt and scan this path directly.
How "inactive" is determined
stale-modules looks at the most recent modification time of your actual source files (ignoring node_modules, .git, and build output like dist, build, .next, .cache, .turbo).
It deliberately does not use git commit history. Plenty of people work locally for a long time without committing, so a project's real activity is better reflected by when its files were last touched than by when they were last pushed.
Hidden/dot directories (.npm, .npm-global, .cache, .nvm, …) are skipped entirely — they hold global installs, caches, and tooling, not projects, so their node_modules are never offered for deletion.
Safety
- Only ever deletes directories literally named
node_modules. Every deletion is guarded — any path whose final segment isn'tnode_modulesis refused. - Nothing is deleted without an explicit confirmation step (which defaults to No).
- Deleting
node_modulesnever touches your source code. It's fully recoverable — just runnpm installin the project again.
Local install (for development)
Clone the repo and link it so the stale-modules (and short alias nmclean) commands work from anywhere:
git clone https://github.com/danilashk/stale-modules.git
cd stale-modules
npm install
npm link # creates global `stale-modules` / `nmclean` commands
nmclean --base ~/code # run from any folder
npm unlink -g stale-modules # undo when you're doneRequirements
- Node.js >= 18
- Works on macOS, Linux, and Windows (verified in CI)
License
MIT
