Skip to content

Building desktop apps downloads a runtime per version, and keeps them

Electron, Node headers and packaged builds accumulate outside your project. Where each cache is and what prunes it.

4 min read

If you build desktop applications, the tooling downloads a complete runtime for every version and platform it has ever been asked to package for, and keeps all of them in a cache outside your project.

Where the caches are

du -sh ~/Library/Caches/electron ~/Library/Caches/electron-builder \
  ~/.electron ~/.node-gyp ~/Library/Caches/node-gyp 2>/dev/null | sort -h
CacheWhat it holdsSafe to clear
electronRuntime zips per version and architectureYes
electron-builderPackaging tools and code signing helpersYes
node-gypNode headers per version, for native modulesYes
Project dist or outYour packaged applicationsYes, rebuild
node_modules/.cacheBundler outputYes

Why it multiplies

A universal build for macOS needs both architectures. Supporting two Electron versions doubles it again. Add Windows and Linux targets built from the same Mac and the cache holds a runtime per version per platform per architecture, none of which is removed when you upgrade.

Packaged output is the other half

find ~ -maxdepth 5 -type d \( -name dist -o -name out -o -name release \) \
  -mtime +90 2>/dev/null -exec du -sh {} + | sort -h | tail -15

A packaged application is the size of a browser, because it contains one. A few builds of a few versions sitting in a project's output folder is several gigabytes, and every one of them is regenerated by running the build again.

Cleaning up

  1. Remove cached runtimes for Electron versions you no longer build against.
  2. Clear packaged output in projects you are not actively releasing.
  3. Clear node-gyp headers for Node versions you have removed.
  4. Rebuild once to confirm the versions you do use are refetched cleanly.

This sits alongside the other Node caches on the same machine, which are covered in the npm cache and the Node versions nvm keeps.

Common questions

Where does Electron cache downloaded runtimes?

In ~/Library/Caches/electron, with packaging tools cached separately in electron-builder's own directory. Both hold one copy per version and architecture.

Why is my Electron cache so large?

Because it keeps a runtime per version, per platform and per architecture, and upgrading adds rather than replaces. Universal macOS builds double it, and cross platform targets multiply it further.

Is it safe to delete the node-gyp cache?

Yes. It holds Node headers used to compile native modules, downloaded again when needed. Clearing it costs a download the next time a native module is built.

Can I delete packaged app builds?

Yes, they are regenerated by running the build again. The exception is a signed release you have shipped and have not archived anywhere else.

Read next