Dependency management for Denox using the deno CLI at build-time.
Manages npm/jsr packages declared in deno.json via deno install.
In Deno 2.x, vendoring is handled by setting "vendor": true in
deno.json and running deno install, which creates node_modules/
for npm packages in the same directory as deno.json.
The deno CLI is only required at build-time, not at runtime.
Workflow
# 1. Declare deps in deno.json
# 2. Install deps
Denox.Deps.install()
# 3. Create a runtime with installed deps
{:ok, rt} = Denox.Deps.runtime()
# 4. Use bare specifier imports
Denox.eval_async(rt, ~s[
import { z } from "zod";
export default z.string().parse("hello");
]) |> Task.await()
Summary
Functions
Add a dependency to deno.json and reinstall.
Check if dependencies have been installed.
Install all dependencies declared in deno.json.
List dependencies declared in deno.json.
Remove a dependency from deno.json and reinstall.
Create a runtime configured to load from the installed deps directory.
Functions
Add a dependency to deno.json and reinstall.
Examples
Denox.Deps.add("zod", "npm:zod@^3.22")
Denox.Deps.add("@std/path", "jsr:@std/path@^1.0")
Check if dependencies have been installed.
Looks for node_modules/ in the config directory as evidence
that deno install has been run.
Options:
:config- path to deno.json (default: "deno.json"):vendor_dir- legacy option, checks if this directory exists
Returns :ok or {:error, message}.
Install all dependencies declared in deno.json.
Sets "vendor": true in the config and runs deno install,
which creates node_modules/ for npm packages in the config directory.
Options:
:config- path to deno.json (default: "deno.json")
Returns :ok or {:error, message}.
List dependencies declared in deno.json.
Returns {:ok, %{name => specifier}} or {:error, message}.
Remove a dependency from deno.json and reinstall.
@spec runtime(keyword()) :: {:ok, Denox.runtime()} | {:error, String.t()}
Create a runtime configured to load from the installed deps directory.
Options:
:config- path to deno.json (default: "deno.json"):cache_dir- cache directory for remote fetches (default: "_denox/cache"):import_map- map of bare specifiers to resolved URLs/paths- Additional options passed to
Denox.runtime/1
Returns {:ok, runtime} or {:error, message}.