Open-Source Wikis

/

Deno

/

Reference

/

Cache layout (`DENO_DIR`)

denoland/deno

Cache layout (DENO_DIR)

Where Deno stores its caches on disk, and which code reads/writes each location.

Where DENO_DIR lives

By default:

OS Path
Linux $XDG_CACHE_HOME/deno or ~/.cache/deno
macOS ~/Library/Caches/deno
Windows %LOCALAPPDATA%\deno

Override with the DENO_DIR environment variable. Resolution lives in libs/cache_dir.

Layout

$DENO_DIR/
├── deps/                    # HTTPS imports
│   └── https/
│       └── <host>/
│           └── <hash>...    # cached file content + metadata
├── npm/                     # npm packages (auto-managed mode)
│   └── registry.npmjs.org/
│       └── <package>/
│           └── <version>/
│               └── ...      # extracted package contents
├── gen/                     # transpiled JS for TS sources, keyed by source hash
├── check/                   # type-check results, keyed by graph hash
├── bench/                   # `deno bench` results
├── lint/                    # `deno lint` cache
├── code_cache/              # V8 bytecode cache for warm starts
└── unstable/                # opt-in for some unstable features

The exact subdirectory names and layout are managed by:

  • libs/cache_dir — root directory resolution
  • cli/cache/ — the CLI's cache structures (parsed source, emit, type-check)
  • libs/npm_cache — npm tarball + registry response cache

What writes where

Cache Written by Read by When invalidated
deps/ cli/file_fetcher.rs All HTTPS imports deno cache --reload, deno clean
npm/ libs/npm_installer/ libs/node_resolver/ deno install --reload, deno clean
gen/ cli/module_loader.rs (transpilation) cli/module_loader.rs (loading) Source content hash change
check/ cli/type_checker.rs cli/type_checker.rs Graph hash change, compiler options change
code_cache/ runtime/code_cache.rs V8 isolate startup Source content hash change

Cleaning

deno clean              # remove most caches
deno clean --dry-run    # show what would be deleted
deno clean --keep-deps  # keep deps/ but clear gen/, check/, etc.

The implementation is in cli/tools/clean.rs (~18K bytes). It carefully only removes Deno's own caches, never user files.

Lockfile interaction

Independent of the cache: the project lockfile (deno.lock) lives in the project directory, not in DENO_DIR. It records resolved versions + integrity hashes for npm/jsr/HTTPS dependencies and is the source of truth for which version to use; the cache is just where the content sits.

A mismatch between the lockfile and the cached content is an integrity-check failure and aborts the run. If you've manually corrupted the cache, deno cache --reload re-fetches.

Where the code lives

Path Purpose
libs/cache_dir/ DENO_DIR resolution, layout constants
cli/cache/ CLI-side cache structures
libs/npm_cache/ npm-specific cache
cli/tools/clean.rs deno clean implementation
cli/file_fetcher.rs Writes deps/ for HTTPS imports
runtime/code_cache.rs V8 bytecode cache
cli/type_checker.rs Type-check results cache

Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.

Cache layout (`DENO_DIR`) – Deno wiki | Factory