Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions runtime/reference/cli/add.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,16 @@ deno add --npm express
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`](/runtime/fundamentals/configuration/).

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

```sh
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`](/runtime/reference/cli/install/),
[`deno remove`](/runtime/reference/cli/remove/), and
[`deno uninstall`](/runtime/reference/cli/uninstall/).
16 changes: 16 additions & 0 deletions runtime/reference/cli/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,22 @@ 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 --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.

```sh
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`.

### deno install --entrypoint [FILES]

Use this command to install all dependencies that are used in the provided files
Expand Down