deno compile: Build a Standalone Binary
deno compile produces a self-contained executable that bundles the Deno runtime, your code, and its dependencies.
For shipping a CLI artifact from CI, deno compile yields one binary per platform with no runtime to install on the target.
What it does
deno compile resolves the module graph, embeds it with the runtime, and writes a native executable. Permission flags passed at compile time are baked in, so the binary runs with exactly those permissions.
Common usage
deno compile --output mycli main.ts
deno compile --allow-net --allow-read --output mycli main.ts
# cross-compile for another platform
deno compile --target x86_64-unknown-linux-gnu --output mycli-linux main.tsOptions
| Flag | What it does |
|---|---|
| --output <name> | Name of the produced executable |
| --target <triple> | Cross-compile, e.g. x86_64-pc-windows-msvc |
| --allow-net / --allow-read | Permissions baked into the binary |
| --include <path> | Include extra files or modules in the binary |
| --no-check | Skip type-checking during compile |
| --icon <file> | Set the executable icon (Windows target) |
In CI
Run a matrix over --target values to produce one binary per platform, then upload them as artifacts. Cache DENO_DIR so the dependency download is not repeated for each target. Bake only the permissions the tool truly needs.
Common errors in CI
"error: Module not found" during compile means an import cannot be resolved; the entry graph must be complete. "Dynamic import not allowed" or a missing asset means you need --include for files loaded at runtime. A wrong --target string fails with "Unknown target"; use a supported triple such as aarch64-apple-darwin.