Command line usage:
deno compile [OPTIONS] [SCRIPT_ARG]...Compiles the given script into a self contained executable.
deno compile --allow-read --allow-net jsr:@std/http/file-server
deno compile --output file_server jsr:@std/http/file-server
Any flags specified which affect runtime behavior will be applied to the resulting binary.
This allows distribution of a Deno application to systems that do not have Deno installed. Under the hood, it bundles a slimmed down version of the Deno runtime along with your JavaScript or TypeScript code.
Cross-compiling to different target architectures is supported using the --target flag.
On the first invocation of deno compile, Deno will download the relevant binary and cache it in $DENO_DIR.
--check Jump to headingSet type-checking behavior. This subcommand type-checks local modules by default, so adding --check is redundant
If the value of "all" is supplied, remote modules will be included.
Alternatively, the 'deno check' subcommand can be used.
--no-check Jump to headingSkip type-checking. If the value of "remote" is supplied, diagnostic errors from remote modules will be ignored.
--cached-only Jump to headingRequire that remote dependencies are already cached.
--frozen Jump to headingError out if lockfile is out of date.
--import-map Jump to headingLoad import map file from local file or remote URL.
--lock Jump to headingCheck the specified lock file. (If value is not provided, defaults to "./deno.lock").
--no-lock Jump to headingDisable auto discovery of the lock file.
--no-npm Jump to headingDo not resolve npm modules.
--no-remote Jump to headingDo not resolve remote modules.
--node-modules-dir Jump to headingSets the node modules management mode for npm packages.
--reload Jump to headingShort flag: -r
Reload source code cache (recompile TypeScript) no value Reload everything jsr:@std/http/file-server,jsr:@std/assert/assert-equals Reloads specific modules npm: Reload all npm modules npm:chalk Reload specific npm module.
--vendor Jump to headingToggles local vendor folder usage for remote modules and a node_modules folder for npm packages.
--allow-scripts Jump to headingAllow running npm lifecycle scripts for the given packages
Note: Scripts will only be executed when using a node_modules directory (--node-modules-dir).
--cert Jump to headingLoad certificate authority from PEM encoded file.
--conditions Jump to headingUse this argument to specify custom conditions for npm package exports. You can also use DENO_CONDITIONS env var. .
--config Jump to headingShort flag: -c
Configure different aspects of deno including TypeScript, linting, and code formatting.
Typically the configuration file will be called deno.json or deno.jsonc and
automatically detected; in that case this flag is not necessary.
--env-file Jump to headingLoad environment variables from local file Only the first environment variable with a given key is used. Existing process environment variables are not overwritten, so if variables with the same names already exist in the environment, their values will be preserved. Where multiple declarations for the same environment variable exist in your .env file, the first one encountered is applied. This is determined by the order of the files you pass as arguments.
--ext Jump to headingSet content type of the supplied file.
--location Jump to headingValue of globalThis.location used by some web APIs.
--minimum-dependency-age Jump to heading(Unstable) The age in minutes, ISO-8601 duration or RFC3339 absolute timestamp (e.g. '120' for two hours, 'P2D' for two days, '2025-09-16' for cutoff date, '2025-09-16T12:00:00+00:00' for cutoff time, '0' to disable).
--no-code-cache Jump to headingDisable V8 code cache feature.
--no-config Jump to headingDisable automatic loading of the configuration file.
--preload Jump to headingA list of files that will be executed before the main module.
--require Jump to headingA list of CommonJS modules that will be executed before the main module.
--seed Jump to headingSet the random number generator seed.
--v8-flags Jump to headingTo see a list of all available flags use --v8-flags=--help
Flags can also be set via the DENO_V8_FLAGS environment variable.
Any flags set with this flag are appended after the DENO_V8_FLAGS environment variable.
--exclude Jump to headingExcludes a file/directory in the compiled executable. Use this flag to exclude a specific file or directory within the included files. For example, to exclude a certain folder in the bundled node_modules directory.
--icon Jump to headingSet the icon of the executable on Windows (.ico).
--include Jump to headingIncludes an additional module or file/directory in the compiled executable. Use this flag if a dynamically imported module or a web worker main module fails to load in the executable or to embed a file or directory in the executable. This flag can be passed multiple times, to include multiple additional modules.
--no-terminal Jump to headingHide terminal on Windows.
--output Jump to headingShort flag: -o
Output file (defaults to $PWD/
--target Jump to headingTarget OS architecture.
As with deno install, the runtime flags
used to execute the script must be specified at compilation time. This includes
permission flags.
deno compile --allow-read --allow-net jsr:@std/http/file-server
Script arguments can be partially embedded.
deno compile --allow-read --allow-net jsr:@std/http/file-server -p 8080
./file_server --help
You can cross-compile binaries for other platforms by using the --target flag.
# Cross compile for Apple Silicon
deno compile --target aarch64-apple-darwin main.ts
# Cross compile for Windows with an icon
deno compile --target x86_64-pc-windows-msvc --icon ./icon.ico main.ts
Deno supports cross compiling to all targets regardless of the host platform.
| OS | Architecture | Target |
|---|---|---|
| Windows | x86_64 | x86_64-pc-windows-msvc |
| macOS | x86_64 | x86_64-apple-darwin |
| macOS | ARM64 | aarch64-apple-darwin |
| Linux | x86_64 | x86_64-unknown-linux-gnu |
| Linux | ARM64 | aarch64-unknown-linux-gnu |
It is possible to add an icon to the executable by using the --icon flag when
targeting Windows. The icon must be in the .ico format.
deno compile --icon icon.ico main.ts
# Cross compilation with icon
deno compile --target x86_64-pc-windows-msvc --icon ./icon.ico main.ts
By default, statically analyzable dynamic imports (imports that have the string
literal within the import("...") call expression) will be included in the
output.
// calculator.ts and its dependencies will be included in the binary
const calculator = await import("./calculator.ts");
But non-statically analyzable dynamic imports won't:
const specifier = condition ? "./calc.ts" : "./better_calc.ts";
const calculator = await import(specifier);
To include non-statically analyzable dynamic imports, specify an
--include <path> flag.
deno compile --include calc.ts --include better_calc.ts main.ts
Starting in Deno 2.1, you can include files or directories in the executable by
specifying them via the --include <path> flag.
deno compile --include names.csv --include data main.ts
Then read the file relative to the directory path of the current module via
import.meta.dirname:
// main.ts
const names = Deno.readTextFileSync(import.meta.dirname + "/names.csv");
const dataFiles = Deno.readDirSync(import.meta.dirname + "/data");
// use names and dataFiles here
Note this currently only works for files on the file system and not remote files.
Similarly to non-statically analyzable dynamic imports, code for workers is not included in the compiled executable by default. There are two ways to include workers:
--include <path> flag to include the worker code.deno compile --include worker.ts main.ts
// main.ts
import "./worker.ts";
deno compile main.ts
By default, on macOS, the compiled executable will be signed using an ad-hoc
signature which is the equivalent of running codesign -s -:
$ deno compile -o main main.ts
$ codesign --verify -vv ./main
./main: valid on disk
./main: satisfies its Designated Requirement
You can specify a signing identity when code signing the executable just like you would do with any other macOS executable:
codesign -s "Developer ID Application: Your Name" ./main
Refer to the official documentation for more information on codesigning and notarization on macOS.
On Windows, the compiled executable can be signed using the SignTool.exe
utility.
$ deno compile -o main.exe main.ts
$ signtool sign /fd SHA256 main.exe