Where apps hide your files
Global package folders depend on how Node was installed, so the exact path comes from a command. This covers that command, the caches for npm, pnpm and Yarn, and safe cleanup.
Where global packages go depends on how Node was installed, so the reliable answer is a command:
npm root -g
npm prefix -g
npm config get cache
npm root -g prints the folder that holds global packages. Typical results on a Mac:
/usr/local/lib/node_modules Node from the nodejs.org installer, or Homebrew on Intel
/opt/homebrew/lib/node_modules Homebrew on Apple silicon
~/.nvm/versions/node/<version>/lib/node_modules nvm
On the Mac used to check this guide, Node comes from nvm, so npm root -g prints ~/.nvm/versions/node/v22.22.1/lib/node_modules. Each Node version managed by nvm has its own global folder, which is why a global tool can vanish after you switch versions.
The npm documentation says global packages go to {prefix}/lib/node_modules and their commands are linked into {prefix}/bin, where the prefix defaults to the place Node is installed. The cache is ~/.npm.
To open a folder, press ⇧⌘G in Finder and paste the path, or run open "$(npm root -g)".
| Item | Location |
|---|---|
| Global packages | $(npm root -g), that is <prefix>/lib/node_modules |
| Global commands | <prefix>/bin, symlinks into the package folders |
| Download cache | ~/.npm/_cacache |
| Debug logs | ~/.npm/_logs |
| Per-project packages | node_modules/ inside each project |
List what is installed globally with npm ls -g --depth=0. That reads only package names and versions.
The cache holds content-addressed tarballs and metadata, in folders such as content-v2 and index-v5 inside _cacache. You never need to edit it by hand. It is safe to clear because npm downloads again what it needs: npm cache verify checks and tidies it, and npm cache clean --force empties it. Both are commands for you to run when you decide to; stopping running dev servers first avoids confusing errors.
pnpm keeps a single store and puts files into each project's node_modules from it. On macOS its default import method tries cloning first (APFS copy-on-write copies), then hard links, so the same file is not stored once per project. Ask for the locations:
pnpm store path
pnpm root -g
pnpm's documentation gives ~/Library/pnpm/store as the macOS default. On this Mac, with pnpm 9, the active store is ~/Library/pnpm/store/v3 and global packages are in ~/Library/pnpm/global/5/node_modules. The v3 and 5 folder names are layout versions that change between pnpm releases: the same store folder here also holds v10 and v11 stores left by newer pnpm versions, and the whole ~/Library/pnpm folder is 3.6 GB.
Run pnpm store prune to remove packages no project references any more. pnpm's documentation says it "is not harmful and has no side effects on your projects"; removed packages are downloaded again if needed. It works on the store that pnpm store path prints, so an old vNN folder from a release you no longer use has to be removed separately, in Finder, once nothing uses that pnpm version. Do not delete files inside the active store by hand: pnpm keeps an index of what the store holds, and prune is the supported way to shrink it.
Yarn 1 (classic) and Yarn 2 and later (Berry) store things differently, so check yarn --version first.
For Yarn 1, yarn cache dir shows the cache, which on this Mac is ~/Library/Caches/Yarn/v6. yarn global dir prints the global package folder, here ~/.config/yarn/global (the folder only appears once you install something globally). yarn cache clean empties the cache.
For modern Yarn, the documentation lists enableGlobalCache: true and globalFolder: "${HOME}/.yarn/berry" as defaults, so downloaded packages are shared from a cache under ~/.yarn/berry. Projects that set enableGlobalCache: false keep zipped packages in .yarn/cache inside the project instead. Modern Yarn has no yarn global; it expects you to run tools per project.
The safe space savers, in order:
npm cache clean --force, pnpm store prune, yarn cache clean. All three refill on demand.npm uninstall -g <name>, not by deleting folders.node_modules folders in old projects (in Finder, move them to the Trash). npm install rebuilds them from package.json and the lockfile.Do not delete the global node_modules folder wholesale if you rely on globally installed tools such as typescript or vercel, and leave the npm folder in it alone (along with corepack, in Node versions that bundle it), because those came with Node itself.
Global packages are not worth copying, since they are tied to a Node version and chip. Record them with npm ls -g --depth=0, install Node on the new Mac, and reinstall the ones you use. Caches should not be copied at all.
~/.npm, ~/.nvm and ~/.config are hidden dot-folders, and ~/Library, home of the pnpm store and the Yarn cache, is left out of Spotlight results. On the Mac used for this guide, a Spotlight query for _cacache returned nothing.
When you are hunting for one package rather than the root, Everywhere is quicker than walking the tree. Typing _cacache or node_modules finds every cache and project folder across the Mac, hidden ones included (a project under Documents or the Desktop shows up once Everywhere has Full Disk Access, since macOS guards both), and typing a package name such as typescript shows each copy and which Node version's folder it sits in. Press ⌘↵ to reveal a hit in Finder. It looks at names only, not the text inside package.json.
In {prefix}/lib/node_modules. Run npm root -g to see the exact folder, which differs for Homebrew, the nodejs.org installer and nvm.
In ~/.npm, with the data in ~/.npm/_cacache. npm config get cache confirms it.
Run pnpm store path. On macOS the default is under ~/Library/pnpm/store, in a versioned subfolder, and pnpm store prune removes unreferenced packages.
If you use nvm, each Node version has its own global folder. Switching versions switches which global packages you see, so reinstall them or switch back.
Everywhere keeps track of every file on your Mac — including the folders Spotlight hides and drives you have unplugged. Free for a day, then $19 once.
Version 2.20.3 · macOS 13+ · 4.7 MB · notarised