Spec-Zone.ru › Deno 2

deno watch

The deno watch command runs a program and reloads it when its source files change. It is a shorthand for deno run --watch-hmr: the program runs with hot module replacement enabled, so on a change Deno swaps the updated modules in place where it can instead of doing a full restart.

Usage

›_
deno watch main.ts

This is equivalent to:

›_
deno run --watch-hmr main.ts

Because deno watch reuses deno run, every deno run flag works, including the watch options:

  • --watch-hmr=<paths> adds extra paths to watch.
  • --watch-exclude=<paths> excludes paths from triggering a reload.
  • --no-clear-screen keeps previous output instead of clearing the screen on each reload.
›_
deno watch --watch-exclude=dist/ -RN main.ts
Command line usage:
deno watch [OPTIONS] [SCRIPT_ARG]...

Run a JavaScript or TypeScript program, watching for file changes and hot-replacing modules.

This is an alias for deno run --watch-hmr. The process restarts if hot replacement fails.

deno watch main.ts

Local files from the entry point module graph are watched by default. Additional paths can be passed with --watch-hmr:

deno watch --watch-hmr=./templates main.ts

Type checking options

--check<CHECK_TYPE>optional

Enable 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.

--no-check<NO_CHECK_TYPE>optional

Skip type-checking. If the value of "remote" is supplied, diagnostic errors from remote modules will be ignored.

Dependency management options

--cached-only

Require that remote dependencies are already cached.

--frozen<BOOLEAN>optional

Error out if lockfile is out of date.

--import-map<FILE>

Load import map file from local file or remote URL.

--lock<FILE>optional

Check the specified lock file. (If value is not provided, defaults to "./deno.lock").

--no-lock

Disable auto discovery of the lock file.

--no-npm

Do not resolve npm modules.

--no-remote

Do not resolve remote modules.

--node-modules-dir<MODE>optional

Selects 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-linker<MODE>

Sets the linker mode for npm packages (isolated or hoisted).

--reload, -r<CACHE_BLOCKLIST>optional

Reload 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.

--vendor<vendor>optional

Toggles local vendor folder usage for remote modules and a node_modules folder for npm packages.

Options

--allow-scripts<PACKAGE>optional

Allow running npm lifecycle scripts for the given packages Note: Scripts will only be executed when using a node_modules directory (--node-modules-dir).

--cert<FILE>

Load certificate authority from PEM encoded file.

--conditions<conditions>

Use this argument to specify custom conditions for npm package exports. You can also use DENO_CONDITIONS env var. .

--config, -c<FILE>

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.

--coverage<DIR>optional

Collect 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.

--cpu-prof

Start the V8 CPU profiler on startup and write the profile to disk on exit. Profiles are written to the current directory by default.

--cpu-prof-dir<DIR>

Directory where the V8 CPU profiles will be written. Implicitly enables --cpu-prof.

--cpu-prof-flamegraph

Generate an SVG flamegraph alongside the CPU profile.

--cpu-prof-interval<MICROSECONDS>

Sampling interval in microseconds for CPU profiling (default: 1000).

--cpu-prof-md

Generate a human-readable markdown report alongside the CPU profile.

--cpu-prof-name<NAME>

Filename for the CPU profile (defaults to CPU...cpuprofile).

--env-file<FILE>optional

Load 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<ext>

Set content type of the supplied file.

--location<HREF>

Value of globalThis.location used by some web APIs.

--minimum-dependency-age<minimum-dependency-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-code-cache

Disable V8 code cache feature.

--no-config

Disable automatic loading of the configuration file.

--preload<FILE>

A list of files that will be executed before the main module.

--require<FILE>

A list of CommonJS modules that will be executed before the main module.

--seed<NUMBER>

Set the random number generator seed.

--tunnel, -t<tunnel>optional

Execute tasks with a tunnel to Deno Deploy.

Create a secure connection between your local machine and Deno Deploy, providing access to centralised environment variables, logging, and serving from your local environment to the public internet.

--use-env-proxy

Use HTTP_PROXY, HTTPS_PROXY, and NO_PROXY for node:http/node:https.

--v8-flags<V8_FLAGS>optional

To 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.

Debugging options

--inspect<HOST_PORT>optional

Activate 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-brk<HOST_PORT>optional

Activate inspector on host:port, wait for debugger to connect and break at the start of user script.

--inspect-wait<HOST_PORT>optional

Activate inspector on host:port and wait for debugger to connect before running user code.

File watching options

--no-clear-screen

Do not clear terminal screen when under watch mode.

--watch<FILES>optional

Watch 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-exclude<FILES>optional

Exclude provided files/patterns from watch mode.

--watch-hmr<FILES>optional

Watch 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.

Last updated on June 25, 2026

© 2018–2025 the Deno authors
Licensed under the MIT License.
https://docs.deno.com/runtime/reference/cli/watch

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API