deno cache: Pre-Download Dependencies
deno cache fetches and caches every dependency of a module graph without running the code.
Running deno cache as its own step pre-warms DENO_DIR so later run and test steps are offline-fast and reproducible.
What it does
deno cache resolves the import graph from the entry points you name, downloads each remote dependency, and stores it in DENO_DIR. In Deno 2, "deno install" with no package argument is the preferred way to do this from deno.json; deno cache still works for explicit entry files.
Common usage
deno cache main.ts
deno cache --frozen main.ts
deno cache --reload main.ts
# warm the cache for tests too
deno cache main.ts deps.ts test_deps.tsOptions
| Flag | What it does |
|---|---|
| --frozen | Fail if the lockfile would change |
| --reload[=specifiers] | Re-download, ignoring the cache (optionally scoped) |
| --lock <file> | Use a specific lockfile path |
| --no-check | Cache without type-checking |
| --cached-only | Do not fetch; require everything already cached |
In CI
Set DENO_DIR to a path you restore from the CI cache, run deno cache --frozen as the first step, then run and test with --cached-only so the network is never touched again. --frozen guarantees the lockfile is authoritative.
Common errors in CI
"error: The lockfile is out of date" under --frozen means deno.lock no longer matches imports; regenerate and commit. "error: Import ... failed: 404 Not Found" means a remote specifier is gone or wrong. With --cached-only, "Specifier not found in cache" means DENO_DIR was not restored before the step.