Skip to content

The caches native npm modules leave behind: headers, binaries and Corepack

Native npm modules download Node headers and prebuilt binaries into caches npm never clears. Measured: 192 MB across node-gyp, ffmpeg-static and Corepack.

4 min read

Most npm packages are JavaScript. A few are compiled, such as image processors, database drivers and file watchers, and those either download a prebuilt binary or compile against Node's headers. Both leave a cache behind, and none of them is the npm cache.

CachePathSizeWhat
node-gyp~/Library/Caches/node-gyp/22.14.053 MBNode headers, one folder per Node version
ffmpeg-static~/Library/Caches/ffmpeg-static-nodejs92 MBDownloaded ffmpeg binaries
Corepack~/.cache/node/corepack47 MBDownloaded Yarn and pnpm versions

Why they pile up

  • node-gyp keeps a header folder for every Node version you have compiled against. Switching versions with a version manager adds one each time.
  • Packages that bundle a tool, such as ffmpeg-static, sharp or puppeteer, download it once per version into a cache named after the package.
  • Corepack downloads every Yarn and pnpm version any project asks for.

Find and clear them

ls ~/Library/Caches | grep -iE 'node|gyp|ffmpeg|sharp|electron|prebuild'
du -sh ~/Library/Caches/node-gyp/* ~/.cache/node/* 2>/dev/null

# All safe to remove; they are downloads
rm -rf ~/Library/Caches/node-gyp ~/Library/Caches/ffmpeg-static-nodejs

The next npm install of a native module fetches only what the current Node needs. Larger downloads of the same kind are the Electron and Playwright caches, in the Electron cache and Playwright browsers. The main npm cache is in npm cache taking up space.

Common questions

Where is the node-gyp cache on a Mac?

In ~/Library/Caches/node-gyp, with one folder of Node headers for each Node version you have built native modules against.

Is it safe to delete the node-gyp cache?

Yes. node-gyp downloads the headers again the next time a native module is built.

What is the Corepack cache?

Copies of the Yarn and pnpm versions your projects asked for, kept in ~/.cache/node/corepack. It is safe to clear.

Does npm cache clean remove these caches?

No. node-gyp, Corepack and packages like ffmpeg-static keep their own caches outside npm's.

Read next