Skip to main content
On this page

Build CLI apps

Deno is a great way to ship command-line tools. Your tool is just TypeScript, so there's no build step to run it. When you're ready to distribute it, deno compile turns it into a single self-contained executable that runs without Deno installed.

Read command-line arguments Jump to heading

Raw arguments are available on Deno.args. For real tools, parse them with @std/cli, which handles flags, options, and defaults:

greet.ts
import { parseArgs } from "jsr:@std/cli/parse-args";

const flags = parseArgs(Deno.args, {
  string: ["name"],
  default: { name: "world" },
});

console.log(`Hello, ${flags.name}!`);
>_
$ deno run greet.ts --name=Deno
Hello, Deno!

Compile to a single executable Jump to heading

deno compile bundles your program and the Deno runtime into one binary: no node_modules, no install step for your users.

>_
deno compile greet.ts
./greet --name=Deno

Name the binary with --output. If your tool needs permissions, bake them in with the usual --allow-* flags so it runs without prompting:

>_
deno compile --output greet greet.ts

Cross-compile for other platforms Jump to heading

Build for a platform other than your own with --target, so you can ship binaries for Windows, macOS, and Linux from one machine:

>_
deno compile --target x86_64-pc-windows-msvc --output greet.exe greet.ts
deno compile --target aarch64-apple-darwin --output greet greet.ts

See deno compile for every target and flag, including embedding assets and setting an icon.

Install a tool from source Jump to heading

To make a script available as a command on your own machine (without compiling), install it globally with deno install:

>_
deno install --global --name greet greet.ts
greet --name=Deno

Going further Jump to heading

Did you find what you needed?

Edit this page
Privacy policy