diff --git a/runtime/fundamentals/modules.md b/runtime/fundamentals/modules.md index 7644732ab..a13b17e5b 100644 --- a/runtime/fundamentals/modules.md +++ b/runtime/fundamentals/modules.md @@ -624,12 +624,17 @@ are semantically "development time" dependencies, like (`@types/*`), are often defined in `dependencies` in `package.json` files, which means they are installed for production even though they are not needed. -Because of this, Deno uses a different approach for installing production only -dependencies: when running `deno install`, you can pass a `--entrypoint` flag -that causes Deno to install only the dependencies that are actually -(transitively) imported by the specified entrypoint file. Because this is -automatic, and works based on the actual code that is being executed, there is -no need to specify development dependencies in a separate field. +Deno offers two approaches for installing production-only dependencies: + +- **`deno install --prod`** — skips `devDependencies` from `package.json`. You + can also pass `--skip-types` to additionally exclude `@types/*` packages. +- **`deno install --entrypoint`** — installs only the dependencies that are + actually (transitively) imported by the specified entrypoint file. When + combined with `--prod`, type-only dependencies are also excluded from the + module graph. + +See the [`deno install` reference](/runtime/reference/cli/install/) for more +details. ## Using only cached modules diff --git a/runtime/reference/cli/install.md b/runtime/reference/cli/install.md index 517e68792..364a2772a 100644 --- a/runtime/reference/cli/install.md +++ b/runtime/reference/cli/install.md @@ -177,6 +177,50 @@ This combines the behavior of [`deno compile`](/runtime/reference/cli/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`. + +```sh +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`. + +#### --skip-types + +When combined with `--prod`, the `--skip-types` flag additionally skips +`@types/*` packages from both `package.json` dependencies and `deno.json` +imports: + +```sh +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: + +```sh +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 packages npm packages like