Deno Cache on Mac: What DENO_DIR Holds and How to Clear It

Medium riskPackage managers & build toolsUpdated

Facts from the app
Location
  • ~/Library/Caches/deno
Risk level
Medium riskSafe to remove, but the tool that owns it re-downloads or rebuilds it on next use, which costs time and bandwidth. Listed, never pre-selected.
Selected by default
No — you choose whether to include it
What Freshist does
Moves the selected items to the Trash, so you can undo. Nothing is deleted outright.
In the app
Clean → Deno Cache — “Deno dependency cache — re-downloaded on next run.”

From Freshist's own cleaning rules — the same catalog the app uses.

What lives in the Deno cache

Deno doesn't use a per-project install step by default. When a script imports jsr:, npm: or an https:// URL, Deno downloads the code once and keeps it in a global cache called DENO_DIR. On macOS that folder is ~/Library/Caches/deno unless you override it, and deno info prints each part of it:

SubfolderContents
remote/Remote modules fetched over HTTPS, including JSR packages
npm/npm packages used by projects without a local node_modules
gen/Transpiled JavaScript from TypeScript, and other emitted code
registries/Data the language server uses for import completions
location_data/Origin storage, such as localStorage for scripts run with --location

Web cache storage (the caches API) is kept separately in the system temporary folder, as deno info shows.

How it builds up

Every version of every remote module you import stays cached. The npm/ folder behaves like npm's own store, with one copy per package version. Working on several Deno or Fresh projects, or running scripts straight from URLs, builds that up quickly. gen/ grows too, since Deno stores emitted JavaScript for each TypeScript file it has compiled.

Deno doesn't prune this folder on its own schedule. It stays until you clear it.

What happens if you delete it

  • The next deno run, deno test or deno task downloads its dependencies again and re-transpiles TypeScript, so the first run is slower.
  • deno.json, deno.lock and your source files aren't in the cache; versions stay pinned by the lockfile.
  • Origin storage under location_data/ is lost. If a script stores data with localStorage and a fixed --location, that data goes too.
  • The REPL history file, which lives in DENO_DIR by default, is removed.
  • Editor features backed by the language server rebuild their data in the background.

Look before you clear

deno info                    # DENO_DIR and each cache folder
du -sh ~/Library/Caches/deno
du -sh ~/Library/Caches/deno/*
deno clean --dry-run         # what clean would remove

Clear it with Deno

deno clean

The deno clean reference describes it as removing Deno's global module cache directory. Two options make it more selective:

  • --dry-run lists what would be removed without deleting anything.
  • --except <files> (or -e) keeps the cache data the given entry points need and removes the rest. That's useful when you want to keep one active project ready offline.

Quit editors running the Deno language server first, so it doesn't rewrite files while they're being removed. If you have an older Deno without deno clean, upgrade with deno upgrade, or delete the folder deno info reports.

Times to keep it

Keep the cache before travel or offline work, or on a slow connection with large npm dependencies. To pre-fetch a project instead of relying on the cache from an earlier run, deno install in the project folder downloads everything up front. Clear it when old projects are gone or a corrupted download breaks a run. If you also use Bun or npm, they keep separate stores: see the Bun cache and npm cache guides.

Sources

Frequently asked questions

Does deno clean remove my REPL history?

It can. Deno's docs say DENO_REPL_HISTORY defaults to deno_history.txt inside DENO_DIR, so emptying that folder takes the history file with it. Copy it out first if you want to keep it.

Are projects with a node_modules folder affected?

Less so. If a project uses a local node_modules directory, its npm packages are installed there and keep working. Projects that resolve npm packages from the global cache need them downloaded again.

How do I keep the cache somewhere else?

Set the DENO_DIR environment variable to another folder. Deno uses it for all caches, and deno info prints the new location.

Keep reading