If you have been developing on macOS for a while, you have likely noticed that Node.js tooling quietly accumulates a surprising amount of disk space. Understanding the npm cache location on Mac — along with where global packages live — is the first step toward reclaiming that space safely. This guide covers every relevant path for npm, npx, Yarn, pnpm, and nvm on both Apple Silicon and Intel Macs running macOS Sequoia or Tahoe, with exact commands you can paste into Terminal right now.
The npm Cache: Where It Lives and How Big It Gets
npm keeps a content-addressable cache of every package tarball it has ever downloaded. On macOS the default location is:
~/.npm
That tilde expands to your home directory, so the full path is typically /Users/yourname/.npm. Inside you will find a _cacache folder that stores compressed tarballs indexed by content hash, plus a _logs folder and an _npx folder for one-off npx executions.
To confirm the exact path npm is using on your machine, run:
npm config get cache
On a fresh macOS install the output will be /Users/yourname/.npm. If you have ever customised your npm config or used certain version managers, it could point elsewhere — always check rather than assume.
Cache size varies enormously. A developer who has worked across many projects over a few years can easily accumulate 5–15 GB here. Run this to see your current total:
du -sh ~/.npm
Global Package Prefix: Where npm install -g Puts Things
Global packages are stored under npm's prefix, which is a separate location from the cache. On macOS with a system Node.js installation (from nodejs.org or Homebrew), the default prefix is:
- nodejs.org installer:
/usr/local— packages land in/usr/local/lib/node_modules, binaries in/usr/local/bin - Homebrew (Intel):
/usr/local/lib/node_modules - Homebrew (Apple Silicon):
/opt/homebrew/lib/node_modules - nvm-managed Node:
~/.nvm/versions/node/<version>/lib/node_modules
Check your own prefix at any time with:
npm config get prefix
And list everything you have installed globally:
npm list -g --depth=0
nvm and Node Version Manager Footprints
If you manage Node.js versions with nvm, each installed version lives in its own directory:
~/.nvm/versions/node/
A typical nvm installation with three or four Node versions — each carrying its own copy of globally installed packages — can reach 2–4 GB. You can see every installed version with:
nvm list
And remove a version you no longer need with:
nvm uninstall 18.20.4
That command deletes the entire version directory including its global packages, which is far more thorough than trying to clean manually.
Yarn and pnpm Cache Locations on macOS
If your projects use Yarn or pnpm instead of (or alongside) npm, those tools maintain their own caches:
- Yarn Classic (v1):
~/Library/Caches/Yarn - Yarn Berry (v2/v3/v4):
~/Library/Caches/yarn— though Berry projects can also use a per-project.yarn/cache - pnpm:
~/Library/Caches/pnpm
Yarn's cache in ~/Library/Caches is the macOS-conventional location for user-level application caches, which means it will show up in Finder's storage breakdown and in any disk-audit tool that scans the Caches folder. Confirm your Yarn cache location with:
yarn cache dir
And for pnpm:
pnpm store path
Full Path Reference Table
The table below summarises every significant npm-ecosystem disk location on macOS. Sizes are typical ranges, not guarantees — a single monorepo with many dependencies can exceed any estimate here.
| Location | Tool | Typical Size | Safe to Delete? |
|---|---|---|---|
~/.npm/_cacache |
npm | 1–15 GB | Yes — npm re-downloads on next install |
~/.npm/_npx |
npx | 50–500 MB | Yes — repopulates on next npx run |
/usr/local/lib/node_modules |
npm global (Intel / nodejs.org) | 200 MB–2 GB | Only remove packages you don't need |
/opt/homebrew/lib/node_modules |
npm global (Apple Silicon Homebrew) | 200 MB–2 GB | Only remove packages you don't need |
~/.nvm/versions/node/ |
nvm | 500 MB–4 GB | Remove unused Node versions via nvm uninstall |
~/Library/Caches/Yarn |
Yarn Classic | 500 MB–5 GB | Yes — Yarn re-fetches on next install |
~/Library/Caches/pnpm |
pnpm | 500 MB–8 GB | Yes — pnpm re-fetches on next install |
How to Clear the npm Cache on macOS (Step by Step)
Before deleting anything, let npm verify its own cache integrity so you are not removing data that is already corrupt or duplicated:
- Verify first:
npm cache verify— this prunes unreferenced data and fixes permissions. Often reclaims space without a full wipe. - Check the size:
du -sh ~/.npm— confirm how much is there. - Clear if needed:
npm cache clean --force— wipes~/.npm/_cacacheentirely. The--forceflag is required as of npm 5+. - Clear Yarn cache (if used):
yarn cache clean - Clear pnpm store (if used):
pnpm store prune— this is smarter than a full delete; it removes only packages no longer referenced by any local project.
None of these steps removes your installed projects or their node_modules folders. They only remove the cached download copies. Your next npm install will simply re-download what it needs — often from a CDN, so speed is rarely a concern on a modern connection.
For a broader look at which other developer caches are silently accumulating space — Xcode derived data, CocoaPods, Gradle, Maven, Rust — see our guide on how to clean up node_modules on Mac, which covers the full Node.js project footprint alongside these package manager caches.
Related Developer Cache Locations Worth Knowing
npm is rarely the only offender. If you are doing a thorough disk cleanup, these adjacent paths are worth checking:
- node_modules (per project): Scattered throughout your project tree — find them with
find ~ -name node_modules -type d -maxdepth 5 2>/dev/null - Xcode DerivedData:
~/Library/Developer/Xcode/DerivedData— can reach tens of GB on active iOS/macOS projects. See our article on why Xcode takes up so much space for details. - CocoaPods:
~/Library/Caches/CocoaPods - Cargo (Rust):
~/.cargo/registryand~/.cargo/git - Maven (Java):
~/.m2/repository - Gradle:
~/.gradle/caches - pip (Python):
~/Library/Caches/pip
Across a typical full-stack developer's machine, these caches combined can account for 30–60 GB of storage. A tool like Crumb can audit all of these at once and show what is safe to remove before you delete anything, which is especially useful when you are not sure which projects are still active.
Checking npm and Package Manager Config on macOS Sequoia and Tahoe
macOS Sequoia (15.x) and Tahoe (26.x, the upcoming 2026 release) do not change npm's default paths, but two things to keep in mind:
- System Integrity Protection (SIP): On Apple Silicon Macs, Homebrew installs under
/opt/homebrewprecisely because/usr/localis no longer writeable without elevated permissions on ARM. If you see permission errors withnpm install -g, your prefix is probably pointing at a protected path — fix it by switching to nvm or setting a user-owned prefix in~/.npmrc. - .npmrc prefix override: If a line like
prefix=/some/custom/pathexists in~/.npmrc, that overrides everything. Check withcat ~/.npmrc.
The safest long-term setup on any Apple Silicon Mac is to manage Node versions through nvm, which keeps everything under your home directory and avoids permission issues entirely. This also makes cleanup straightforward: one nvm uninstall command removes a version and its global packages cleanly.