Bottom Line: It is 100% safe to clear .nx/cache. Nx uses local computation caching to skip previously executed build and test tasks. Wiping the cache simply forces Nx to re-execute tasks.
Why Does Nx Workspace Cache Exist?
Nx monorepos utilize computation caching to accelerate CI pipelines and local developer builds. When you run nx build my-app or nx test my-app, Nx hashes your source files, dependencies, and environment flags.
- Primary Purpose: Skipping redundant builds, lints, and unit tests across monorepo packages.
- Storage Impact: Large monorepos with dozens of projects accumulate gigabytes of cached build artifacts inside
.nx/cache, consuming 2 GB to 20 GB+. - Location: Stored locally in
<workspace-root>/.nx/cacheornode_modules/.cache/nx.
What Happens If You Clear Nx Cache?
- System Safety: ✅ 100% Safe to Delete. No source code or git history is lost.
- Build Impact: Subsequent Nx commands will execute all tasks fresh rather than pulling cached task outputs.
- Reclaimed Storage: Reclaims 2 GB to 20 GB+ of local SSD storage.
How to Clear Nx Cache Safely
Method 1: Using Official Nx CLI Command
npx nx reset
Method 2: Manual Terminal Deletion
rm -rf .nx/cache node_modules/.cache/nx
Frequently Asked Questions (FAQ)
What does npx nx reset do?
npx nx reset stops running Nx daemon background processes and deletes the local .nx/cache directory.
Does clearing local Nx cache affect Nx Cloud remote cache?
No. Clearing local .nx/cache only deletes local disk task outputs. Remote caches stored on Nx Cloud remain accessible.
Discussion
Loading authentication...