Node.js ecosystem disk

Where Does npm Store Cache and Global Packages on macOS? (Path Reference)

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:

  1. Verify first: npm cache verify — this prunes unreferenced data and fixes permissions. Often reclaims space without a full wipe.
  2. Check the size: du -sh ~/.npm — confirm how much is there.
  3. Clear if needed: npm cache clean --force — wipes ~/.npm/_cacache entirely. The --force flag is required as of npm 5+.
  4. Clear Yarn cache (if used): yarn cache clean
  5. 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/registry and ~/.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/homebrew precisely because /usr/local is no longer writeable without elevated permissions on ARM. If you see permission errors with npm 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/path exists in ~/.npmrc, that overrides everything. Check with cat ~/.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.

Reclaim your disk in one click

Crumb audits your whole Mac, tells you what's safe to delete, and frees the space in seconds — private, local, and Apple-notarized.

Download Crumb for macOS

Frequently asked questions

Is it safe to delete the npm cache on macOS?
Yes. The npm cache at ~/.npm is a download cache only — it does not contain your project code or installed node_modules. Running `npm cache clean --force` removes it, and npm will rebuild the cache automatically the next time you run `npm install` in any project.
Where exactly is the npm cache on a Mac?
The default location is ~/.npm on macOS, which expands to /Users/yourname/.npm. You can confirm the exact path your npm installation is using by running `npm config get cache` in Terminal.
Will clearing the npm cache break my existing projects?
No. Clearing the cache does not touch your project folders, node_modules directories, or package-lock.json files. The only effect is that your next `npm install` will download packages from the network rather than reading from the local cache.
Where does npm install -g put packages on Apple Silicon Macs?
With a Homebrew-managed Node.js on Apple Silicon, global packages go to /opt/homebrew/lib/node_modules and their binaries to /opt/homebrew/bin. With nvm, global packages are stored under ~/.nvm/versions/node/<version>/lib/node_modules. Run `npm config get prefix` to see your exact location.
How much disk space does the npm cache typically use?
On an active development machine, the npm cache can range from a few hundred megabytes to 15 GB or more depending on how many projects you have worked on and how long ago you last cleared it. Run `du -sh ~/.npm` to check your current usage.