SpaceFreeSpaceFree
← All guides

How to clear npm, pip and NuGet caches on Windows

By Bhavik · Sources checked September 19, 2026

Package managers keep downloaded packages so the next install is fast. Over time those caches can get large. Clearing them is safe in the sense that they are only copies, but the next install has to download again.

npm

The npm cache lives at %LocalAppData%\npm-cache on Windows. npm cache clean --force deletes all data from the cache folder. npm's documentation says clearing is usually unnecessary because the cache is self-healing, which is why the command needs --force. npm cache verify checks the cache and removes data that is no longer needed (npm cache).

npm cache verify
npm cache clean --force

pip

pip cache has subcommands to show the cache folder (dir), show information about it (info), list its files (list), remove specific packages (remove) and remove everything (purge) (pip cache).

pip cache dir
pip cache info
pip cache purge

NuGet (.NET)

On Windows, NuGet keeps the global packages folder at %userprofile%\.nuget\packages, its HTTP cache at %localappdata%\NuGet\v3-cache, and temp files at %temp%\NuGetScratch (managing NuGet folders). List the exact locations on your machine with:

dotnet nuget locals all --list

Clear one folder or all of them:

dotnet nuget locals http-cache --clear
dotnet nuget locals global-packages --clear
dotnet nuget locals all --clear
After clearing the global packages folder you need to restore your projects again to download the packages, and NuGet's docs say it does not currently provide a command to remove only unused packages (source). Close Visual Studio first, since files in use can block the clear.

If you work inside WSL

Caches created by tools running inside a WSL distribution live inside that distribution's virtual disk. Clearing them frees space inside the disk, but Windows only gets the space back once you compact it. See Why your WSL2 disk file never shrinks.

Doing this without the command line

SpaceFree scans your drive for package caches, build folders and virtual disks, shows their sizes, and tags each item as safe to delete, rebuildable or not cleanable before anything is removed. Download SpaceFree.

Sources