Spec-Zone.ru › Deno 2

deno install

deno install installs dependencies and caches them for your project. For more on how Deno handles modules, see Modules and dependencies.

Examples

deno install

Use this command to install all dependencies defined in deno.json and/or package.json.

The dependencies will be installed in the global cache, but if your project has a package.json file, a local node_modules directory will be set up as well.

deno install [PACKAGES]

Use this command to install particular packages and add them to deno.json or package.json.

›_
deno install jsr:@std/testing npm:express
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 install express is equivalent to deno install npm:express. JSR packages still need the jsr: prefix to stay unambiguous. The npm: prefix remains required in import specifiers.

Tip

You can also use deno add which is an alias to deno install [PACKAGES]

If your project has a package.json file, the packages coming from npm will be added to dependencies in package.json. Otherwise all packages will be added to deno.json.

deno install --os and --arch

Starting in Deno 2.8, deno install accepts --os and --arch flags so you can install npm packages targeting a different platform than the one you're running on. This is most useful for pre-installing packages with native binaries — for example, building a deployment artifact on a macOS dev machine that will eventually run on Linux/arm64.

The flags accept Node.js-compatible values, the same strings that process.platform and process.arch produce.

›_
# Install npm packages for linux/arm64
deno install --os linux --arch arm64

# Install for windows/x64
deno install --os win32 --arch x64

# Override just the architecture; --os defaults to the current system
deno install --arch x64

--os and --arch are local-install-only and conflict with --global.

deno install --package-json

By default, Deno picks the configuration file to write to (deno.json or package.json) based on which one is closest to the current working directory. Starting in Deno 2.8, --package-json forces dependencies to be written to package.json, regardless of any nearby deno.json. If no package.json exists yet, one is created.

›_
deno install --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 add, deno remove, and deno uninstall.

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

deno install --entrypoint [FILES]

Use this command to install all dependencies that are used in the provided files and their dependencies.

This is particularly useful if you use jsr:, npm:, http: or https: specifiers in your code and want to cache all the dependencies before deploying your project.

main.js
import * as colors from "jsr:@std/fmt/colors";
import express from "npm:express";
›_
deno install -e main.js
Download jsr:@std/fmt
Download npm:express
Tip

If you want to set up a local node_modules directory, you can pass the --node-modules-dir=auto flag.

Some dependencies might not work correctly without a local node_modules directory.

deno install --global [PACKAGE_OR_URL]

Use this command to install the provided package or script as a globally available binary on your system.

This command creates a thin, executable shell script which invokes deno using the specified CLI flags and main module. It is placed in the installation root.

Example:

›_
deno install --global --allow-net --allow-read jsr:@std/http/file-server
Download jsr:@std/http/file-server...

✅ Successfully installed file-server.
/Users/deno/.deno/bin/file-server

To change the executable name, use -n/--name:

›_
deno install -g -N -R -n serve jsr:@std/http/file-server

The executable name is inferred by default:

  • Attempt to take the file stem of the URL path. The above example would become 'file-server'.
  • If the file stem is something generic like 'main', 'mod', 'index' or 'cli', and the path has no parent, take the file name of the parent path. Otherwise settle with the generic name.
  • If the resulting name has an '@...' suffix, strip it.

To change the installation root, use --root:

›_
deno install -g -N -R --root /usr/local/bin jsr:@std/http/file-server

The installation root is determined, in order of precedence:

  • --root option
  • DENO_INSTALL_ROOT environment variable
  • $HOME/.deno

Executables are placed in the bin subdirectory of the installation root, unless the root path already ends with bin, in which case it is used directly. The resulting directory must be added to the path manually if required.

›_
echo 'export PATH="$HOME/.deno/bin:$PATH"' >> ~/.bashrc

You must specify permissions that will be used to run the script at installation time.

›_
deno install -g -N -R jsr:@std/http/file-server -- -p 8080

The above command creates an executable called file_server that runs with network and read permissions and binds to port 8080.

For good practice, use the import.meta.main idiom to specify the entry point in an executable script.

Example:

// https://example.com/awesome/cli.ts
async function myAwesomeCli(): Promise<void> {
  // -- snip --
}

if (import.meta.main) {
  myAwesomeCli();
}

When you create an executable script make sure to let users know by adding an example installation command to your repository:

›_
# Install using deno install

deno install -n awesome_cli https://example.com/awesome/cli.ts

deno install --global --compile [PACKAGE_OR_URL]

Use this command to compile a package or script into a standalone, self-contained binary. The resulting executable can be distributed and run without requiring Deno to be installed on the target system.

›_
deno install --global --compile -A npm:@anthropic-ai/claude-code

This combines the behavior of deno compile with global installation — producing a native binary placed in the installation root (same as --global without --compile).

deno install --prod

Use this command to install only production dependencies, skipping devDependencies from package.json.

›_
deno install --prod

This is useful when deploying an application where development dependencies like test frameworks or build tools are not needed.

The --prod flag conflicts with --global and --dev.

In CI environments, prefer deno ci --prod, which also enforces a frozen lockfile and removes any pre-existing node_modules before installing.

--skip-types

When combined with --prod, the --skip-types flag additionally skips @types/* packages from both package.json dependencies and deno.json imports:

›_
deno install --prod --skip-types
Caution

The --skip-types flag identifies type packages by checking if the package name starts with @types/. This heuristic may not cover all type-only packages.

--prod with --entrypoint

When --prod is combined with --entrypoint, the module graph is built as "code only", which excludes type-only dependencies:

›_
deno install --prod --entrypoint main.ts

This provides the most precise production install — only dependencies that are actually imported at runtime by the specified entrypoint (and its transitive imports) will be installed.

Native Node.js addons

A lot of popular npm packages like npm:sqlite3 or npm:duckdb depend on "lifecycle scripts", eg. preinstall or postinstall scripts. Most often running these scripts is required for a package to work correctly.

Unlike npm, Deno does not run these scripts by default as they pose a potential security vulnerability.

You can still run these scripts by passing the --allow-scripts=<packages> flag when running deno install:

›_
deno install --allow-scripts=npm:sqlite3

Install all dependencies and allow npm:sqlite3 package to run its lifecycle scripts.

--quiet flag

The --quiet flag suppresses diagnostic output when installing dependencies. When used with deno install, it will hide progress indicators, download information, and success messages.

›_
deno install --quiet jsr:@std/http/file-server

This is useful for scripting environments or when you want cleaner output in CI pipelines.

Uninstall

You can uninstall dependencies or binary script with deno uninstall command:

›_
deno uninstall express
Removed express
›_
deno uninstall -g file-server
deleted /Users/deno/.deno/bin/file-server
✅ Successfully uninstalled file-server

See deno uninstall page for more details.

Command line usage:
deno install [OPTIONS] [cmd]... [-- [SCRIPT_ARG]...]

Installs dependencies either in the local project or globally to a bin directory.

Local installation

Add dependencies to the local project's configuration (deno.json / package.json) and installs them in the package cache. If no dependency is specified, installs all dependencies listed in the config file. If the --entrypoint flag is passed, installs the dependencies of the specified entrypoint(s).

deno install
deno install express
deno install jsr:@std/bytes
deno install --entrypoint entry1.ts entry2.ts

Global installation

If the --global flag is set, installs a script as an executable in the installation root's bin directory.

deno install --global --allow-net --allow-read jsr:@std/http/file-server
deno install -g https://examples.deno.land/color-logging.ts

To change the executable name, use -n/--name:

deno install -g --allow-net --allow-read -n serve jsr:@std/http/file-server

The executable name is inferred by default:

  • Attempt to take the file stem of the URL path. The above example would become file_server.
  • If the file stem is something generic like main, mod, index or cli, and the path has no parent, take the file name of the parent path. Otherwise settle with the generic name.
  • If the resulting name has an @... suffix, strip it.

To change the installation root, use --root:

deno install -g --allow-net --allow-read --root /usr/local jsr:@std/http/file-server

The installation root is determined, in order of precedence:

  • --root option
  • DENO_INSTALL_ROOT environment variable
  • $HOME/.deno

These must be added to the path manually if required.

Type checking options

--check<CHECK_TYPE>optional

Set type-checking behavior. This subcommand type-checks local modules by default, so passing --check is redundant; pass --check=all to also type-check remote modules. Alternatively, use the 'deno check' subcommand.

--no-check<NO_CHECK_TYPE>optional

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

Dependency management options

--cached-only

Require that remote dependencies are already cached.

--frozen<BOOLEAN>optional

Error out if lockfile is out of date.

--import-map<FILE>

Load import map file from local file or remote URL.

--lock<FILE>optional

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

--no-lock

Disable auto discovery of the lock file.

--no-npm

Do not resolve npm modules.

--no-remote

Do not resolve remote modules.

--node-modules-dir<MODE>optional

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<MODE>

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

--reload, -r<CACHE_BLOCKLIST>optional

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.

--vendor<vendor>optional

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

Options

--allow-scripts<PACKAGE>optional

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

--arch<arch>

Target architecture for npm package installation (e.g., x64, arm64).

--cert<FILE>

Load certificate authority from PEM encoded file.

--compile

Install the script as a compiled executable.

--conditions<conditions>

Use this argument to specify custom conditions for npm package exports. You can also use DENO_CONDITIONS env var. .

--config, -c<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.

--dev, -D

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

--entrypoint, -e

Install dependents of the specified entrypoint(s).

--env-file<FILE>optional

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.

--force, -f

Forcefully overwrite existing installation.

--global, -g

Install a package or script as a globally available executable.

--jsr

assume unprefixed package names are jsr packages.

--location<HREF>

Value of globalThis.location used by some web APIs.

--lockfile-only

Install only updating the lockfile.

--minimum-dependency-age<minimum-dependency-age>

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

--name, -n<name>

Executable file name.

--no-config

Disable automatic loading of the configuration file.

--no-save

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

--npm

assume unprefixed package names are npm packages (default).

--os<os>

Target OS for npm package installation (e.g., linux, darwin, win32).

--package-json

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

--preload<FILE>

A list of files that will be executed before the main module.

--prod

Only install production dependencies (excludes devDependencies).

--require<FILE>

A list of CommonJS modules that will be executed before the main module.

--root<root>

Installation root.

--save-exact

Save exact version without the caret (^).

--save-optional, -O

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

--seed<NUMBER>

Set the random number generator seed.

--skip-types

Exclude @types/* packages from installation. Be careful, as it uses a name-based heuristic and may skip packages that ship runtime code.

--unscoped

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.

--v8-flags<V8_FLAGS>optional

To see a list of all available flags use --v8-flags=--help Flags can also be set via the DENO_V8_FLAGS environment variable. Any flags set with this flag are appended after the DENO_V8_FLAGS environment variable.

Debugging options

--inspect<HOST_PORT>optional

Activate inspector on host:port [default: 127.0.0.1:9229]. Host and port are optional. Using port 0 will assign a random free port.

--inspect-brk<HOST_PORT>optional

Activate inspector on host:port, wait for debugger to connect and break at the start of user script.

--inspect-wait<HOST_PORT>optional

Activate inspector on host:port and wait for debugger to connect before running user code.

Last updated on July 2, 2026

© 2018–2025 the Deno authors
Licensed under the MIT License.
https://docs.deno.com/runtime/reference/cli/install

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API