Skip to main content
The deno cache command downloads and compiles modules and their dependencies into the local cache without executing any code.

Usage

deno cache [OPTIONS] [FILE]...

Description

Download and compile a module with all of its static dependencies and save them in the local cache. Future runs of this module will trigger no downloads or compilation unless --reload is specified.

Flags

--reload
boolean | string
Reload source code cache (recompile TypeScript). Can optionally specify specific modules to reload
--lock
string
Check the specified lock file
--lock-write
boolean
Force overwriting the lock file
--import-map
string
Load import map file
--node-modules-dir
boolean
Enables or disables the use of a local node_modules folder for npm packages
--vendor
boolean
Toggles local vendor folder usage for remote modules and a node_modules folder for npm packages
--config
string
Specify the configuration file
--no-config
boolean
Disable automatic loading of the configuration file
--no-remote
boolean
Do not resolve remote modules
--no-npm
boolean
Do not resolve npm modules
--check
boolean | string
Enable type-checking. Can optionally specify “all” to type-check all code including remote modules
--allow-scripts
string
Allow running npm lifecycle scripts for specified packages
--allow-import
string
Allow importing from specified hosts
--deny-import
string
Deny importing from specified hosts

Examples

Cache a module and its dependencies

deno cache main.ts

Cache a remote module

deno cache jsr:@std/http/file-server
deno cache https://deno.land/std/http/file_server.ts

Cache with type checking

deno cache --check main.ts

Cache multiple modules

deno cache mod1.ts mod2.ts mod3.ts

Cache with import map

deno cache --import-map=import_map.json main.ts

Reload and recache

Force redownload and recompilation:
deno cache --reload main.ts
Reload only specific modules:
deno cache --reload=jsr:@std/http main.ts

Build docs developers (and LLMs) love