| title | Command line interface | ||||
|---|---|---|---|---|---|
| description | An overview of Deno's command-line interface: running scripts, common flags, and key subcommands. | ||||
| oldUrl |
|
The Deno CLI lets you run scripts, manage dependencies, run tests, format code, and more. You can view all available commands by running:
deno helpFor detailed documentation on every subcommand and flag, see the CLI reference guide.
Run a local TypeScript or JavaScript file:
deno run main.tsYou can also pipe code from stdin:
cat main.ts | deno run -By default, Deno runs programs in a sandbox without access to disk, network, or
environment. Use --allow-* flags to grant access:
# Allow network and file read access
deno run --allow-net --allow-read server.ts
# Grant all permissions (not recommended for production)
deno run -A server.tsLearn more about permissions and security.
Arguments passed after the script name are available via Deno.args:
$ deno run main.ts arg1 arg2 arg3
[ "arg1", "arg2", "arg3" ]:::caution
Deno flags must come before the script name. Anything after the script name is treated as a script argument, not a Deno flag:
# Good — grants net permission
deno run --allow-net server.ts
# Bad — --allow-net is passed to Deno.args instead
deno run server.ts --allow-net:::
Use --watch to automatically restart on file changes during development:
deno run --watch server.ts
deno test --watch| Command | Description |
|---|---|
deno run |
Execute a script |
deno serve |
Run an HTTP server |
deno test |
Run tests |
deno fmt |
Format source code |
deno lint |
Lint source code |
deno check |
Type-check without running |
deno add |
Add a dependency to deno.json |
deno install |
Install dependencies |
deno compile |
Compile to a standalone binary |
deno task |
Run a task defined in deno.json |
deno doc |
Generate documentation |
Each command has its own flags — run deno <command> --help for details, or
browse the CLI reference.