Skip to main content
The deno run command executes JavaScript or TypeScript programs with the Deno runtime.

Usage

deno run [OPTIONS] <SCRIPT> [SCRIPT_ARGS]...

Basic Examples

# Run a local file
deno run main.ts

# Run a remote file
deno run https://deno.land/std/examples/welcome.ts

# Run with permissions
deno run --allow-net --allow-read server.ts

# Run with arguments
deno run main.ts --port 8000

# Run from stdin
cat script.ts | deno run -

Permission Flags

--allow-all
boolean
Allow all permissions (equivalent to enabling all permission flags)
--allow-env
string
Allow environment access
# Allow all environment variables
deno run --allow-env script.ts

# Allow specific variables
deno run --allow-env=HOME,USER script.ts
--allow-read
string
Allow file system read access
# Allow reading all files
deno run --allow-read script.ts

# Allow reading specific directories
deno run --allow-read=/tmp,/var/log script.ts
--allow-write
string
Allow file system write access
# Allow writing all files
deno run --allow-write script.ts

# Allow writing to specific directory
deno run --allow-write=./output script.ts
--allow-net
string
Allow network access
# Allow all network access
deno run --allow-net script.ts

# Allow specific domains
deno run --allow-net=deno.land,github.com script.ts
--allow-run
string
Allow running subprocesses
# Allow running any subprocess
deno run --allow-run script.ts

# Allow running specific programs
deno run --allow-run=git,npm script.ts
--allow-sys
string
Allow access to system information
# Allow all system APIs
deno run --allow-sys script.ts

# Allow specific system APIs
deno run --allow-sys=osRelease,hostname script.ts
--allow-ffi
string
Allow loading dynamic libraries (Foreign Function Interface)
deno run --allow-ffi script.ts
deno run --allow-ffi=./lib.so script.ts

Deny Flags

Each permission has a corresponding deny flag:
--deny-env
string
Deny environment access
--deny-read
string
Deny file system read access
--deny-write
string
Deny file system write access
--deny-net
string
Deny network access
--deny-run
string
Deny running subprocesses
--deny-sys
string
Deny system information access
--deny-ffi
string
Deny FFI access

Runtime Options

--no-prompt
boolean
Disable permission prompts (automatically deny any required permissions)
--cached-only
boolean
Require that remote dependencies are already cached
--location
string
Set a custom location for the script
deno run --location https://example.com script.ts
--seed
number
Set the seed for the random number generator
deno run --seed=42 script.ts
--v8-flags
string
Set V8 command line options
deno run --v8-flags=--max-old-space-size=8192 script.ts

Watch Mode

--watch
string
Watch for file changes and restart automatically
# Watch the script and its dependencies
deno run --watch main.ts

# Watch specific paths
deno run --watch=src/,config/ main.ts

# Watch with exclude patterns
deno run --watch --watch-exclude=test/ main.ts
--watch-hmr
boolean
Watch for file changes and reload using Hot Module Replacement
deno run --watch-hmr main.ts
--no-clear-screen
boolean
Don’t clear the screen when watch mode restarts

Type Checking

--check
string
Enable type checking (optionally specify which modules to check)
# Type-check all modules
deno run --check main.ts

# Type-check only local modules
deno run --check=local main.ts
--no-check
boolean
Skip type checking (default for deno run)

Module Resolution

--import-map
string
Load import map file
deno run --import-map=import_map.json main.ts
--node-modules-dir
boolean
Create a node_modules directory for npm packages
deno run --node-modules-dir main.ts
--vendor
boolean
Enable vendoring of remote modules

Coverage

--coverage
string
Collect coverage profile data into the specified directory
deno run --coverage=cov_profile main.ts

Configuration

--config
string
Load configuration from a file
deno run --config=deno.json main.ts
--no-config
boolean
Disable automatic configuration file detection

Lock File

--lock
string
Check the specified lock file
deno run --lock=deno.lock main.ts
--no-lock
boolean
Disable lock file
--frozen
boolean
Error if lock file is out of date

Environment

--env
string
Load environment variables from a file
deno run --env=.env main.ts
deno run --env=.env.local,.env main.ts

Inspector

--inspect
string
Activate inspector on host:port (default: 127.0.0.1:9229)
deno run --inspect main.ts
deno run --inspect=0.0.0.0:9229 main.ts
--inspect-brk
string
Activate inspector and break at start of user script
--inspect-wait
string
Activate inspector and wait for debugger to connect before running user code

Examples

Basic Server

// server.ts
Deno.serve(() => new Response("Hello, World!"));
deno run --allow-net server.ts

File Operations

// file-ops.ts
const text = await Deno.readTextFile("./data.txt");
await Deno.writeTextFile("./output.txt", text.toUpperCase());
deno run --allow-read=./data.txt --allow-write=./output.txt file-ops.ts

Subprocess Execution

// git-info.ts
const command = new Deno.Command("git", {
  args: ["log", "-1"],
});
const { stdout } = await command.output();
console.log(new TextDecoder().decode(stdout));
deno run --allow-run=git git-info.ts

Build docs developers (and LLMs) love