KOEN
All notes
FILES & RECOVERY

Should the largest node_modules go first?

A fictional cleanup list prompted by npkill’s documentation. Folder size and age leave questions about current use and the work needed to recover an environment.

A hand pausing with a blank yellow tag over a large blue box connected to a lit desk lamp

The first row by size

Imagine a development-folder cleanup list. A large node_modules sits at the top when sorted by size. A small, old experiment sits below it. When the goal is to recover space quickly, the first row is tempting.

That row gave me pause while reading npkill’s official README. Its profiles find candidates including node_modules, build artifacts and caches. Results can be sorted by size, path or age.

The same document distinguishes finding candidates from deciding what is safe to remove. It notes that some installed applications need their node_modules directories to work and can break when those directories are deleted.

This is not a hands-on review. No files were scanned or removed for the article. The cleanup list is fictional: a way to think about what I would want to know after seeing the largest folder.

Suppose the first project still serves requests. Its code may not have changed for a long time while it continues to read those dependencies. An old modification time alone would not establish that use has ended. Here, age is a clue to investigate, rather than approval to delete.

What “reinstall it” involves

Now suppose the smaller experiment is not needed for a while. I would still want more than its name: the actual target path and whether anything that must be retained, such as local modifications, is mixed in. The same directory name can occur beneath many different projects.

“We can reinstall it” deserves unpacking too. Which dependencies and settings were used? Will the required packages remain accessible? Are there files to keep separately? A lockfile alone does not answer every question. This scenario lists recovery conditions; it does not report a tested reinstall.

In a fictional remove-and-recreate workflow, I would continue after the directory returned. Does the app start, and can it complete the first required task? Space recovered and a working environment recovered deserve separate observations.

A size-sorted list remains useful: it quickly tells me where to begin looking. I would separate that inspection order from deletion order. A pause to identify current use may be preferable to preparing the working environment again after cleanup.

Back at the first row, the large number is unchanged and the decision is still open. I would like another column beside it: who would need to do what next if this folder disappeared?

Sources

All notes