Guide

How to clear the npm cache on a Mac.

Package managers keep a copy of every package version you have ever installed. Years of projects can leave multiple gigabytes of cache you will never use again. All of it is safe to clear.

Where the caches live and how to clear them

npm keeps its cache in ~/.npm. Check its size and clear it:

du -sh ~/.npm
npm cache clean --force

Yarn (classic) caches in ~/Library/Caches/Yarn:

yarn cache clean

pnpm uses a content-addressable store in ~/Library/pnpm/store; prune unreferenced packages with:

pnpm store prune

Clearing a package manager cache is always safe: the worst case is that the next install re-downloads packages from the registry. Note that pnpm is the exception where blunt deletion is a bad idea — projects hard-link into the store, so use pnpm store prune rather than deleting the folder.

The caches people forget

npm is rarely the biggest offender. On a typical development Mac these also accumulate for years:

Checking them all at once

RepoSweep scans every one of these well-known cache locations in a single pass — npm, Yarn, pip, Homebrew, CocoaPods, Swift Package Manager, Go, Playwright, Gradle, Maven, Cargo, and Xcode — shows how big each is and how it regenerates, and moves what you select to macOS Trash so it stays reversible. Scanning is free without limits; see pricing for cleanup.

Free to scan

Check every developer cache in one pass.

Download RepoSweep