Guide for developers

How to clear old node_modules and build folders on Windows

Every project you have ever built can leave behind folders that a tool will recreate in minutes: node_modules, build, target, .gradle, .dart_tool, Python virtual environments. On an old project they just take space. The trick is removing the right ones.

By Randeep Singh, who makes Klenso and builds apps himself. Last checked 16 November 2026 against Klenso 1.0.1.

Why these are usually safe to remove

These folders are generated. A package manager or build tool fills them from files you keep: package.json and its lock file, a Gradle or Maven build file, pubspec.yaml, a requirements.txt. If those files are still there, one install or build command brings everything back.

Check these first

  • The source file is really there. Without package.json (or the equivalent), you cannot rebuild the folder. Do not delete a node_modules that has nothing to rebuild it from.
  • You have not patched or edited anything inside it. Edits made directly in node_modules are lost on reinstall.
  • The project is genuinely old. A folder you will need next week saves you nothing if you have to wait for a reinstall.
  • It is not a release build you need. A build folder can hold files you shipped, such as an .apk or .aab, or signing material. Look before you delete.
  • It is not inside a folder that syncs to the cloud. A delete there can spread to every device.

Doing it yourself

Delete the folders from File Explorer (they go to the Recycle Bin, but a huge node_modules may be too large for it and be deleted permanently, so check) or use a command-line tool built for the job, such as npkill for Node projects. Reinstall with your usual command when you open the project again.

What Klenso does

Klenso's free scan lists these folders with their sizes and removes nothing. If you clean, it follows strict rules:

  • It only considers node_modules, build, .dart_tool, .gradle, target and Python virtual environments (.venv, venv), and only when a project file proves what the folder is. A virtual environment also needs a requirements file beside it.
  • Nothing in the project, including the folder itself, may have changed for 90 days.
  • It refuses a folder that holds a key or certificate, a nested .git, a release build (.aab, .apk, .ipa), a mapping.txt, or symbols or outputs folders.
  • It never touches a folder directly in your user folder or inside a hidden folder, and never searches folders that sync to the cloud.
  • These folders are removed for good, labelled that way, and you must type CLEAN to confirm.
  • It also lists the common caches (Gradle, npm, pip, Dart pub, Android build) and reports their size.

The full rules are on the what Klenso touches page.

The honest limits

How much you save depends entirely on how many old projects you have. Some package managers share a single store between projects, in which case deleting a project's folder frees less than the number a tool first shows. The scan is free, so you can see the real total before you decide.

Related guides

Get the free scan More guides