deno add: Add Dependencies to deno.json
deno add adds a dependency to the "imports" map in deno.json and updates the lockfile.
deno add (Deno 2) is the package-manager-style way to declare dependencies so imports use bare specifiers instead of full URLs.
What it does
deno add resolves a jsr: or npm: package, records it under "imports" in deno.json with a version constraint, and updates deno.lock. Afterward your code imports the bare name. It is a Deno 2 command.
Common usage
deno add jsr:@std/assert
deno add npm:chalk
deno add jsr:@std/path@^1.0.0
# then in code: import { assert } from "@std/assert";Options
| Item | What it does |
|---|---|
| jsr:<scope>/<name> | Add a package from the JSR registry |
| npm:<name> | Add a package from npm |
| @<version> | Pin a version or range, e.g. @^1.0.0 |
| --dev | Record the dependency as development-only |
In CI
Run deno add locally and commit the updated deno.json and deno.lock; CI should not mutate them. In the pipeline, deno install --frozen then verifies that what was committed resolves cleanly without drift.
Common errors in CI
"error: Package not found" means the jsr:/npm: name or scope is wrong. "Could not find version that satisfies" means the version range matches nothing on the registry. "No deno.json found" means you are not in a project directory; create one or pass --config. Forgetting to commit deno.lock then fails later --frozen steps.