Clear npm, pip, Gradle and NuGet Cache on Windows
To clear npm, pip, Gradle cache on Windows, use each tool's own command where one exists. Caches hold downloads and build data, so your next install or build will be slower.
Where each cache lives
| Tool | Usual Windows location | How to clear |
|---|---|---|
| npm | %LocalAppData%\npm-cache |
npm cache clean --force |
| pip | %LocalAppData%\pip\Cache |
pip cache purge |
| Gradle | %UserProfile%\.gradle\caches |
Manual, after stopping Gradle |
| NuGet | %UserProfile%\.nuget\packages and others |
dotnet nuget locals all --clear |
Settings and environment variables can move these folders. Ask each tool where its cache is before you act. A large file scan or Windows Clean can show which one is worth clearing.
Clear npm cache
npm config get cache
npm cache verify
npm cache clean --force
verify checks the cache and removes unneeded data, so try it first. clean --force empties the cache. Installed global packages are stored elsewhere. See the npm cache documentation.
Clear pip cache
pip cache dir
pip cache info
pip cache purge
The purge command removes both downloaded responses and locally built wheels, as the pip caching guide describes. It does not uninstall packages from your virtual environments. If you use several Python versions, check which one pip belongs to.
Clear Gradle cache
Gradle already cleans old cache data periodically, according to its directory layout guide. Clear it by hand only when you need space now.
- Close Android Studio, IntelliJ IDEA and other build tools.
- Run
gradle --stopor.\gradlew --stop. Check Task Manager for remaining Java build processes. - Delete the contents of the
cachesfolder inside your Gradle user home.
Keep gradle.properties and the init.d folder, because they hold your settings. The next build downloads dependencies again.
Clear NuGet cache
dotnet nuget locals all --list
dotnet nuget locals http-cache --clear
Start with the HTTP cache. To remove downloaded packages too, run dotnet nuget locals global-packages --clear. Projects must then restore their packages again. Microsoft's NuGet guide lists every folder.
Remove old node_modules folders
The npm cache and node_modules are different things. This read-only command lists them under one projects folder:
Get-ChildItem C:\Projects -Directory -Recurse -Filter node_modules |
Where-Object { $_.FullName -notmatch 'node_modules\\.*node_modules' } |
Select-Object FullName
Change C:\Projects to your own path. Delete a folder only if the project has package.json and, ideally, a lock file. Restore it later with npm ci or npm install.
When not to clear npm, pip or Gradle cache on Windows
- You will work offline soon.
- A project depends on a package that is no longer available online.
- A private package source is hard to reach.
- A build is running.
Docker uses separate storage. Read Docker and WSL disk space. For other app data, see what is safe to clean in AppData.
Developer cache FAQ
Will clearing caches delete my source code? The commands above target cache folders, not project files. Check custom paths first.
How often should I clear them? Only when space is short or a cache seems damaged. Regular clearing wastes download time.
Why did the folder grow again? Builds and installs refill it. That is expected.
Windows Clean is a free, offline disk space analyzer for Windows. No cloud, no telemetry.
Download for Windows — Free