On this page
deno run
Usage Jump to heading
Run a local file:
deno run main.ts
The run subcommand is optional — you can also just use deno <file>:
deno main.ts
By default, Deno runs programs in a sandbox without access to disk, network or
ability to spawn subprocesses. This is because the Deno runtime is
secure by default. You can grant or deny
required permissions using the
--allow-* and --deny-* flags.
Permissions examples Jump to heading
Grant permission to read from disk and listen to network:
deno run --allow-read --allow-net server.ts
Grant permission to read allow-listed files from disk:
deno run --allow-read=/etc server.ts
Grant all permissions this is not recommended and should only be used for testing:
deno run -A server.ts
If your project requires multiple security flags you should consider using a
deno task to execute them.
Watch Jump to heading
To watch for file changes and restart process automatically use the --watch
flag. Deno's built in application watcher will restart your application as soon
as files are changed.
Be sure to put the flag before the file name eg:
deno run --allow-net --watch server.ts
Deno's watcher will notify you of changes in the console, and will warn in the console if there are errors while you work.
The same --watch flag is also accepted by
deno test,
deno serve, and
deno bench.
When the watcher restarts the process, Deno sends SIGTERM first so unload
event listeners and process.exit hooks run, then waits 500ms before the hard
kill. This gives graceful-shutdown code time to flush resources between
restarts.
Running a package.json script Jump to heading
package.json scripts can be executed with the
deno task command.
Running code from stdin Jump to heading
You can pipe code from stdin and run it immediately:
echo "console.log('hello')" | deno run -
Terminate run Jump to heading
To stop the run command use ctrl + c.
runRun a JavaScript or TypeScript program, or a task
Options Jump to heading
--allow-scriptsAllow running npm lifecycle scripts for the given packages
Note: Scripts will only be executed when using a node_modules directory (--node-modules-dir).
--cached-onlyRequire that remote dependencies are already cached.
--certLoad certificate authority from PEM encoded file.
--checkEnable type-checking. This subcommand does not type-check by default; pass --check=all to also type-check remote modules. Alternatively, use the 'deno check' subcommand.
Use this argument to specify custom conditions for npm package exports. You can also use DENO_CONDITIONS env var. .
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.
--coverageCollect coverage profile data into DIR. If DIR is not specified, it uses 'coverage/'. This option can also be set via the DENO_COVERAGE_DIR environment variable.
--env-fileLoad 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.
--extSet content type of the supplied file.
--frozen-lockfileError out if lockfile is out of date.
--hmrWatch for file changes and hot-replace modules. The process restarts if hot replacement fails. Local files from entry point module graph are watched by default. Additional paths might be watched by passing them as arguments to this flag.
Load import map file from local file or remote URL.
--inspectActivate inspector on host:port [default: 127.0.0.1:9229]. Host and port are optional. Using port 0 will assign a random free port.
--inspect-brkActivate inspector on host:port, wait for debugger to connect and break at the start of user script.
--inspect-publish-uid--inspect-waitActivate inspector on host:port and wait for debugger to connect before running user code.
--locationValue of globalThis.location used by some web APIs.
--lockCheck the specified lock file. (If value is not provided, defaults to "./deno.lock").
--min-dep-age(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-checkSkip type-checking. If the value of "remote" is supplied, diagnostic errors from remote modules will be ignored.
--no-clear-screenDo not clear terminal screen when under watch mode.
--no-code-cacheDisable V8 code cache feature.
--no-configDisable automatic loading of the configuration file.
--no-lockDisable auto discovery of the lock file.
--no-npmDo not resolve npm modules.
--no-remoteDo not resolve remote modules.
--node-modules-dirSelects the node_modules directory mode for npm packages (not a path). One of: auto (create a local node_modules directory and install npm packages into it), manual (use the existing local node_modules directory, do not modify it), none (do not use a local node_modules directory; resolve npm packages from the global cache). Defaults to auto when the flag is passed without a value.
--node-modules-linkerSets the linker mode for npm packages (isolated or hoisted).
--preloadA list of files that will be executed before the main module.
--reload, -rReload source code cache (recompile TypeScript). With no value, reloads everything. Pass a comma-separated list of specifiers to reload only those modules; npm: reloads all npm modules; npm:chalk reloads a single npm module; jsr:@std/http/file-server,jsr:@std/assert/assert-equals reloads specific modules.
--requireA list of CommonJS modules that will be executed before the main module.
--seedSet the random number generator seed.
--unsafely-ignore-certificate-errorsDANGER: Disables verification of TLS certificates.
--use-env-proxyUse HTTP_PROXY, HTTPS_PROXY, and NO_PROXY for node:http/node:https.
--v8-flagsTo 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.
--vendorToggles local vendor folder usage for remote modules and a node_modules folder for npm packages.
--watchWatch for file changes and restart process automatically. Local files from entry point module graph are watched by default. Additional paths might be watched by passing them as arguments to this flag.
--watch-excludeExclude provided files/patterns from watch mode.
Last updated on