Home › Guides › Delete node_modules and dev caches

Delete node_modules, build output and package caches on Windows

Dependency folders, build output and package caches are safe to delete when you can rebuild or re-download them. Delete project folders like node_modules, target or bin/obj for projects you aren't working on, and clean package caches with each tool's own command (npm cache clean --force, pnpm store prune, uv cache prune, go clean -cache). The next install or build brings back what it needs, at the cost of time and bandwidth.

Project folders

FolderMade byHow it comes back
node_modulesnpm, pnpm, Yarn, Bunnpm install (or your package manager's install)
.next, .nuxt, distNext.js, Nuxt, bundlersThe next build or dev run
targetCargo (Rust), Maven (Java)cargo build, mvn package. In a Rust project, cargo clean removes it
bin, obj.NETdotnet build
build, .gradleGradleThe next Gradle build
.venv, venvPythonRecreate it, for example uv sync or python -m venv .venv plus pip install -r requirements.txt

Only delete a folder when the project file that produced it sits next to it (package.json, Cargo.toml, *.csproj, pyvenv.cfg). A folder called build or bin elsewhere may hold something you can't rebuild. On Windows, rd often handles deep node_modules trees better than Explorer:

cmd /c rd /s /q node_modules

Package caches, with each tool's own command

ToolClean commandNote
npmnpm cache clean --forcenpm cache verify checks and trims the cache without emptying it
pnpmpnpm store pruneRemoves only packages no project references. pnpm store path shows where the store is
Yarnyarn cache cleanyarn cache dir shows the folder
pippip cache purgepip cache dir shows the folder
uvuv cache pruneRemoves unused entries. uv cache clean empties the whole cache in %LOCALAPPDATA%\uv\cache
Gogo clean -cache, go clean -modcacheThe build cache rebuilds itself. The module cache means re-downloading every module
Cargocargo clean (per project)Recent Cargo versions clean old downloads in the Cargo home cache on their own. Most of the space is usually in each project's target
NuGetdotnet nuget locals all --cleardotnet nuget locals all --list shows the folders first
Gradlegradle --stop, then delete %USERPROFILE%\.gradle\cachesStop the daemons first or files stay locked. Everything is downloaded again
MavenDelete folders in %USERPROFILE%\.m2\repositorySee the caveat below about mvn install
Playwrightnpx playwright uninstallAdd --all to also remove browsers from other Playwright installs. Default folder: %USERPROFILE%\AppData\Local\ms-playwright
Hugging Facehf cache ls, hf cache rm <repo>, hf cache pruneModels can be many GB to download again. --dry-run previews

Caveats

How RigSweep's Dev Disk does it

RigSweep is a free, open-source Windows app. Its Dev Disk tab scans your user profile and lists project folders, package caches, GPU and ML caches, AI tool caches and leftover git worktrees with their size.

Prefer a terminal tool for node_modules only? See RigSweep vs npkill. Download RigSweep (Windows 10 and 11, MIT).

FAQ

Is it safe to delete node_modules?

Yes, if the project has a package.json and a lockfile. The next npm install (or pnpm, Yarn or Bun install) restores it. Close dev servers and editors using the project first so no files are locked.

Is it safe to clear the npm cache?

Yes. npm cache clean --force empties it and npm downloads packages again when needed. The only cost is time and bandwidth on the next install.

How do I clean the pnpm store?

Run pnpm store prune. It removes packages that no project references and doesn't affect your projects.

Can I delete the .m2 repository folder?

You can, but artifacts you built with mvn install live only there and come back only when you build those projects again. Everything downloaded from a remote repository is downloaded again.