Skip to content

Every frontend project keeps three caches, and only one is node_modules

The .next, .turbo, .vite and node_modules/.cache folders all grow per project. What each does and which are safe to clear in bulk.

5 min read

Everyone knows about node_modules. Fewer people notice that a modern frontend project keeps at least three more caches beside it, all of them derived, all of them per project, and none of them removed when you stop working on it.

What a project actually holds

FolderMade byRegenerated
node_modulesThe package managerYes, by install
.nextNext.js builds and dev serverYes, by build
node_modules/.cacheBabel, ESLint, webpack and friendsYes
.turboTurborepo task cacheYes
.vite and node_modules/.viteVite dependency pre-bundlingYes
dist or buildYour outputYes, by build

Find them across every project

find ~ -maxdepth 6 -type d \( -name .next -o -name .turbo -o -name .vite \) \
  2>/dev/null -exec du -sh {} + | sort -h | tail -20
find ~ -maxdepth 7 -type d -path '*/node_modules/.cache' \
  2>/dev/null -exec du -sh {} + | sort -h | tail -10

A .next folder on a large site is routinely a gigabyte, and it exists in every project you have run a dev server in, including the tutorial you followed once.

Clearing them in bulk, safely

These are the safest folders on a developer Mac to remove, because every one of them is defined as derived output. The only cost is the next build, and for a project you are not working on there is no next build.

find ~ -maxdepth 6 -type d \( -name .next -o -name .turbo \) \
  -mtime +90 2>/dev/null -print0 | xargs -0 rm -rf

The -mtime +90 filter is what makes that command reasonable rather than reckless: it only touches folders untouched for three months, which excludes anything you are working on.

The remote cache question

If a monorepo uses a remote cache for its task runner, the local .turbo folder is a mirror rather than the only copy, which makes it even safer to remove. That is worth checking once, because it changes the calculation for the whole team.

Once the derived folders are gone, node_modules across every project is the larger number, and the package manager stores are the shared copy behind them.

Common questions

Is it safe to delete the .next folder?

Yes. It holds build output and dev server cache, regenerated by the next build. For a project you are not currently working on, there is no cost at all.

What is node_modules/.cache?

A shared cache directory that build tools write into: Babel, ESLint, webpack and others. It is derived data and is rebuilt automatically, so it can be removed freely.

How do I clear frontend build caches across all my projects?

Use find with -name .next or .turbo and an -mtime filter so only folders untouched for months are removed. That excludes anything you are actively working on.

Does deleting .turbo lose anything?

No. It is a task cache, and if the repository uses a remote cache it is only a local mirror. The worst case is that the next build runs tasks that would otherwise have been cached.

Read next