Deno Knowledge Patch
Use this skill when choosing current Deno runtime APIs, CLI options, configuration, dependency behavior, Node compatibility, or deployment workflows. Open the topic reference before changing a project because several commands, flags, APIs, and defaults changed more than once.
Working approach
- Inspect
deno --version,deno.jsonordeno.jsonc,package.json,deno.lock, workspace files, and CI commands. - Read every reference relevant to the requested change; later version-attributed guidance supersedes earlier behavior only where it explicitly changes it.
- Preserve least-privilege permissions. Do not add
-Amerely to silence a permission failure. - Keep manifest and lockfile changes together, and prefer frozen installation modes in CI.
- Treat the project's manifests, code, tests, and observed behavior as authoritative when they conflict with general guidance.
- Verify with the narrowest applicable built-ins:
deno check,deno lint,deno fmt --check,deno test, and the requested build or package command.
Reference index
| Reference | Topics |
|---|---|
| Build, publish, and deploy | Compilation, bundling, transpilation, packaging, publication, and deployment |
| Dependencies and workspaces | Manifests, registries, npm and JSR resolution, lockfiles, installs, catalogs, and workspaces |
| Desktop and ecosystem | Desktop applications, notebooks, Fresh, Deploy, Sandbox, and registry consumers |
| Deno 2 migration | Removed surfaces, stricter checks, changed output, and changed defaults |
| Networking and observability | HTTP, sockets, TLS, WebSockets, QUIC, inspectors, profiles, and OpenTelemetry |
| Node compatibility | CommonJS, Node APIs, timers, workers, IPC, SQLite, tests, and diagnostics |
| Permissions and security | Permission sets, allow and deny precedence, audit logs, scripts, and supply-chain policy |
| Runtime and Web APIs | Files, subprocesses, WebAssembly, Temporal, cryptography, graphics, and Web APIs |
| Testing, linting, and formatting | Tests, snapshots, retries, sharding, coverage, benchmarks, lint plugins, and formatters |
| Tooling and editor | Type checking, TypeScript configuration, tasks, caching, CLI workflows, upgrades, and language-server behavior |
Migrate breaking surfaces first
Replace removed commands and flags
- Remove
deno vendorworkflows. - Do not assume
deno bundleis still absent: it returned as an experimental esbuild-backed command with npm and JSR support. - Replace explicit-entrypoint
deno cacheworkflows withdeno install --entrypoint. - Remove obsolete
--allow-hrtime,--allow-none,--trace-ops,--ts, generic--unstable,--lock-write, and old--jobsuses. - Check task guidance before removing a newer
deno task --jobsoption because task concurrency later reused that name. - Use specific unstable flags or configuration entries instead of the removed generic flag.
- Upgrade away from the faulty 2.3.0 build to 2.3.1 when version metadata is wrong.
Replace removed runtime APIs
- Replace
Deno.run()withDeno.Commandor current subprocess helpers. - Replace
Deno.serveHttp()withDeno.serve(). - Replace
Deno.isatty()with the applicable terminal property. - Use
Deno.FsFile, Web streams, and current filesystem helpers instead of resource IDs,Deno.File,Deno.Buffer, removed reader and writer interfaces, and resource-oriented free functions. - Do not construct
Deno.FsFiledirectly or read.ridproperties. - Move WebGPU window dimensions to the
UnsafeWindowSurfaceconstructor. - Use current TLS option names; legacy certificate-file and certificate-chain fields were removed.
Reconcile stricter checking and configuration
- Expect unsupported
compilerOptionsto fail validation. - Add
overridewhere required bynoImplicitOverride. - Narrow caught values before use because catch variables are
unknown. - Remove remote import maps and the obsolete
filesfield fromdeno.json. - Account for project
tsconfig.jsondiscovery, references,rootDirs,paths,types,extends,include,exclude, and per-member compiler options. - Update Buffer and typed-array annotations when generic backing-buffer types expose
ArrayBufferversusSharedArrayBufferdifferences.
Recheck changed defaults
- Treat timer handles as Node-style
NodeJS.Timeoutobjects rather than numeric IDs. - Pass
deno fmt .when no configuration or explicit input is discovered. - Enable test operation and resource sanitizers when a suite relies on them.
- Enable
Deno.serve()compression explicitly withautomaticCompression: trueorDENO_SERVE_AUTOMATIC_COMPRESSION=1. - Specify a UDP hostname when binding every interface through the
0.0.0.0default is undesirable. - Account for the default npm minimum-release-age policy or configure another duration.
- Do not infer decoded body size from retained
content-lengthafter automatic decompression. - Pass serializable strings instead of
URLorURLSearchParamsobjects when crossing a serialization boundary.
Manage dependencies deliberately
Choose the target manifest
- Let package commands use the manifest Deno selects, or force
package.jsonwith--package-json. - Set
preferPackageJsonwhen package-management commands should consistently targetpackage.json. - Use
jsr:for JSR package declarations and explicit imports; unprefixed CLI package arguments now default to npm. - Use
--save-exactor--exactwhen reproducibility requires a pinned version instead of the default caret range.
Install and update reproducibly
deno install
deno update
deno update --lockfile-only
deno ci
- Use
deno cionly with a lockfile; it removesnode_modulesand validates a frozen install. - Use
deno install --lockfile-onlyto resolve and update the lock without fetching or installing packages. - Use
deno install --prodto omit development dependencies and type packages. - Use
--osand--archwhen resolving optional dependencies for another target platform. - Inspect dependency paths with
deno whyand declared dependency trees withdeno list.
Configure workspaces and registries
- Combine
deno.jsonandpackage.jsonmembers in one workspace where needed. - Put shared versions in
catalogor namedcatalogs; consume them withcatalog:specifiers. - Use
linksfor local npm redirects; olderpatchconfiguration is deprecated. - Keep scoped registries, authentication, mTLS, release-age, and trust settings in
.npmrc. - Choose isolated or hoisted
node_moduleswithnodeModulesLinkeraccording to tool expectations.
Build and distribute
Bundle or transpile
deno bundle --platform browser --outdir dist app.ts
deno transpile src/mod.ts --outdir dist --source-map separate --declaration
- Use
deno bundlefor a dependency graph; usedeno transpileto strip types without bundling, rewriting modules, or loading project configuration. - Use an HTML entry when module scripts and global CSS should be discovered and rewritten to hashed assets.
- Add
--declarationfor rolled-up declarations and--keep-nameswhen generated names must remain stable.
Compile executables
deno compile --include assets/ --output app main.ts
- Use
--includefor resolved embedded assets and--include-as-isfor verbatim files or directories. - Put
compile.includeandcompile.excludeindeno.jsonwhen asset selection belongs in project configuration. - Use
--self-extractingfor native add-ons or Node APIs that require a real filesystem. - Use experimental
--bundlewith--minifywhen tree-shaking npm-heavy executables matters more than embedding the complete graph. - Set
--app-namewhen compiled KV, local-storage, or Cache data needs a stable application identity.
Package, publish, and deploy
- Use
deno packto create an npm tarball with transpiled exports, declarations, rewritten specifiers, and selected publish assets. - Set
"publish": falseon private workspace members. - Do not publish packages containing raw text or byte imports.
- Use deployment
includeandexcludefilters to select uploaded files.
Test, lint, and format
deno check .
deno lint
deno fmt --check .
deno test --coverage
- Use lifecycle hooks, timeouts, retries, repeats, parameterized cases, and built-in snapshots instead of recreating those mechanisms.
- Use
--changed,--related, and--shard=<index>/<count>for selective or distributed test runs. - Set separate line, branch, and function coverage thresholds when CI must enforce minimums.
- Remember that coverage can include ordinary
deno runentry points and workers, and reports function coverage. - Configure JavaScript lint plugins through
lint.plugins; check the reference for selectors, comments, fixes, permissions, and incomplete ESLint compatibility. - Set explicit formatter policies for named-specifier sorting, JSON trailing commas, embedded languages, and
.editorconfigprecedence.
Use Node compatibility intentionally
- Run ESM Node projects with
package.json, npm workspaces,node_modules, and Node-API add-ons under Deno permissions. - Let
.jsCommonJS detection follow the nearestpackage.json; use compatibility mode only for the bundled fallback behaviors it enables. - Prefer
node:built-in imports for clarity even though bare built-ins now resolve without a flag. - Expect global
Buffer,global,setImmediate, andclearImmediate, plus Node-style timer handles. - Check the Node reference before adding a shim: filesystem, workers, IPC, module hooks, VM modules, networking, TLS, SQLite, test mocks, diagnostics, and crypto expanded substantially.
- Use synchronous
module.registerHooks()for supported resolve and load hooks; do not depend on the intentionally unavailable deprecated registration API.
Keep permissions and supply-chain controls narrow
{
"permissions": {
"local-data": { "read": ["./data"], "write": ["./data"] }
}
}
deno run -P=local-data main.ts
deno audit
- Opt into named permission sets with
-P; configured permissions are never applied implicitly. - Use
--ignore-reador--ignore-envwhen a dependency should observe a denied resource as absent. - Use
DENO_TRACE_PERMISSIONSonly for diagnosis because stack collection is expensive. - Record checks with
DENO_AUDIT_PERMISSIONS, optionally as span-correlated OpenTelemetry logs. - Persist explicit lifecycle-script trust with
deno approve-scripts. - Combine audits, vulnerability fixes, minimum release age, and
trust-policy=no-downgradeaccording to the project's threat model. - Treat an active permission broker as replacing CLI allow, deny, and ignore flags.
Operate servers and telemetry
- Configure
DENO_SERVE_ADDRESS,DENO_AUTO_SERVE,--open, startup callbacks, backlog, and explicit compression for the hosting environment. - Use custom
Deno.HttpClienttransports for Unix sockets, Linux vsock, proxies, or a bound local address; grant the required network permission. - Account for Happy Eyeballs connection racing and set
autoSelectFamily: falseonly when it must be disabled. - Use custom WebSocket headers or an HTTP client only in Deno-specific code because browser constructors do not expose those extensions.
- Enable built-in OpenTelemetry with
OTEL_DENO; choose OTLP or console export and configure sampling and limits through environment variables. - Use inspector traffic capture, CPU profiles, permission logs, and TLS key logging only for deliberate diagnostics, and protect their outputs.
Use modern runtime features
- Use stable
Temporaldirectly. - Import Wasm as a typed module, or use source-phase syntax when a compiled
WebAssembly.Moduleis required. - Use stable text import attributes; keep byte and CSS import stability gates in mind.
- Prefer
usingfor disposable resources where lexical cleanup fits. - Use transferable streams, requests, responses, and structured-clone support instead of unnecessary serialization.
- Feature-detect newer cryptographic algorithms with
SubtleCrypto.supports()before selecting them. - Use Web Locks for shared or exclusive coordination whose lifetime matches an async callback.
Automate tasks and editor workflows
- Express task descriptions and dependencies with object-form tasks; shared dependencies run once.
- Use
filesandoutputto cache deterministic task results, and list environment inputs that affect them. - Control workspace parallelism with
deno task --jobs; use--if-present, wildcards, exclusions, and--env-filewhere appropriate. - Run
deno checkwithout arguments for the current project, add--watchfor continuous checking, and use--check-jsfor JavaScript without file comments. - Expect project-local formatting and compiler settings to affect language-server behavior and auto-import discovery.
- Verify runtime upgrades by checksum when required, and prefer stable artifacts over pull-request builds for production.
Treat desktop support as experimental
- Use
deno desktopfor a webview-hosted native application only when experimental APIs and packaging are acceptable. - Choose the operating-system webview for smaller native integration or CEF for a bundled, consistent engine.
- Read the desktop reference before using
Deno.BrowserWindow, tray, dock, dialogs, bindings, or auto-update APIs.