close
Skip to main content
On this page

deno add

The deno add command adds dependencies to your project's configuration file. It is an alias for deno install [PACKAGES]. For more on how Deno handles dependencies, see Modules and dependencies.

Examples Jump to heading

Add packages from JSR and npm:

>_
deno add npm:express hono zod
deno add jsr:@std/path

Deno 2.8

Unprefixed package names are treated as npm packages by default, so the npm: prefix is no longer required at the CLI. deno add express is equivalent to deno add npm:express. JSR packages still need the jsr: prefix to stay unambiguous. The npm: prefix remains required in import specifiers.

By default, dependencies are added with a caret (^) version range. Use --save-exact to pin to an exact version:

>_
deno add --save-exact @std/path

This saves the dependency without the ^ prefix (e.g., 1.0.0 instead of ^1.0.0).

Where dependencies are stored Jump to heading

If your project has a package.json, npm packages will be added to dependencies in package.json. Otherwise, all packages are added to the imports field in deno.json.

To force every dependency to be written to package.json (creating one if needed), pass --package-json (Deno 2.8+):

>_
deno add --package-json npm:express jsr:@std/path

JSR packages added with --package-json are written in their npm-compatible form (npm:@jsr/...). The same flag works on deno install, deno remove, and deno uninstall.

Command line usage:
deno add [OPTIONS] [packages]...

Add dependencies to your configuration file.

deno add express

Unprefixed packages default to npm. Use jsr: prefix for jsr packages:

deno add jsr:@std/path

Or multiple dependencies at once:

deno add express jsr:@std/path

Options Jump to heading

--allow-scripts<PACKAGE>optional
Jump to heading

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

Add the package as a dev dependency. Note: This only applies when adding to a package.json file.

assume unprefixed package names are jsr packages.

--lockfile-only
Jump to heading

Install only updating the lockfile.

assume unprefixed package names are npm packages (default).

--package-json
Jump to heading

Force using package.json for dependency management instead of deno.json.

--save-exact
Jump to heading

Save exact version without the caret (^).

Dependency management options Jump to heading

--frozen<BOOLEAN>optional
Jump to heading

Error out if lockfile is out of date.

--lock<FILE>optional
Jump to heading

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

Disable auto discovery of the lock file.

Last updated on

Did you find what you needed?

Privacy policy