Skip to main content
On this page

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.

To make this the default without passing the flag each time, set "preferPackageJson": true in deno.json.

Command line usage:
add

Add dependencies

Options Jump to heading

--allow-import, -I
Jump to heading

Allow importing from remote hosts. Optionally specify allowed IP addresses and host names, with ports as necessary. Default value: deno.land:443,jsr.io:443,esm.sh:443,raw.esm.sh:443,cdn.jsdelivr.net:443,raw.githubusercontent.com:443,gist.githubusercontent.com:443.

--allow-scripts
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).

Load certificate authority from PEM encoded 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.

--deny-import
Jump to heading

Deny importing from remote hosts. Optionally specify denied IP addresses and host names, with ports as necessary.

Add the package as a dev dependency (under devDependencies). Note: this only applies when adding to a package.json file.

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.

--frozen-lockfile
Jump to heading

Error out if lockfile is out of date.

Load import map file from local file or remote URL.

assume unprefixed package names are jsr packages.

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

--lockfile-only
Jump to heading

Install only updating the lockfile.

--min-dep-age
Jump to heading

(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).

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

--no-config
Jump to heading

Disable automatic loading of the configuration file.

Disable auto discovery of the lock file.

Do not resolve npm modules.

--no-remote
Jump to heading

Do not resolve remote modules.

Install the package(s) without adding them to the configuration file.

--node-modules-dir
Jump to heading

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
Jump to heading

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

assume unprefixed package names are npm packages (default).

--package-json
Jump to heading

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

--reload, -r
Jump to heading

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.

--save-exact
Jump to heading

Save exact version without the caret (^).

--save-optional, -O
Jump to heading

Add the package as an optional dependency (under optionalDependencies). Note: this only applies when adding to a package.json file.

--unsafely-ignore-certificate-errors
Jump to heading

DANGER: Disables verification of TLS certificates.

Use the package name without its scope as the alias (ex. jsr:@david/jsonc-morph is added as jsonc-morph). Packages given an explicit alias are unaffected.

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

Last updated on

Did you find what you needed?

Edit this page
Privacy policy