Skip to main content
On this page

deno update 会更新你的 deno.jsonpackage.json 中的依赖项。有关依赖项管理的更多信息,请参阅 Modules

更新依赖项 Jump to heading

默认情况下,update 子命令只会更新到符合 semver 兼容的版本(即不会更新到破坏性版本)。

›_
deno update
Updated 1 dependency:
 - jsr:@std/fmt 1.0.0 -> 1.0.3

如果要更新到最新版本(无论是否符合 semver 兼容),请添加 --latest 标志。

›_
deno update --latest
Updated 3 dependencies:
 - jsr:@std/async 1.0.1 -> 1.0.8
 - jsr:@std/fmt   1.0.0 -> 1.0.3
 - npm:chalk      4.1.2 -> 5.3.0

选择包 Jump to heading

update 子命令也支持选择要操作的包。

›_
deno update --latest chalk
Updated 1 dependency:
 - npm:chalk 4.1.2 -> 5.3.0

可以传入多个选择器,并且支持通配符 (*) 和排除 (!)。

例如,要更新所有带有 @std 作用域的包,除了 @std/fmt

›_
deno update --latest "@std/*" "!@std/fmt"
Updated 1 dependency:
 - jsr:@std/async 1.0.1 -> 1.0.8

注意,如果使用通配符,通常需要用引号将参数括起来,以防止 shell 尝试展开它们。

更新到特定版本 Jump to heading

你也可以通过在 @ 后附加版本号来选择要更新到的特定版本。

›_
deno update chalk@5.2 @std/async@1.0.6
Updated 2 dependencies:
 - jsr:@std/async 1.0.1 -> 1.0.6
 - npm:chalk      4.1.2 -> 5.2.0

工作区 Jump to heading

在工作区环境中,默认情况下,update 只会操作 当前 工作区成员。

例如,给定如下工作区:

deno.json
{
  "workspace": ["./member-a", "./member-b"]
}

./member-a 目录运行

›_
deno update

将只更新 ./member-a/deno.json./member-a/package.json 中列出的依赖项。

要包含所有工作区成员,请传入 --recursive 标志(也接受 -r 简写)。

›_
deno update --recursive
deno update --latest -r
Command line usage:
deno update [OPTIONS] [filters]...

Update outdated dependencies.

Update dependencies to the latest semver compatible versions:

deno update

Update dependencies to the latest versions, ignoring semver requirements:

deno update --latest

Update dependencies within their existing version ranges, without editing deno.json / package.json (like npm update):

deno update --lockfile-only

This command is an alias of deno outdated --update

Filters can be used to select which packages to act on. Filters can include wildcards (*) to match multiple packages.

deno update --latest "@std/*"
deno update --latest "react*"

Note that filters act on their aliases configured in deno.json / package.json, not the actual package names: Given "foobar": "npm:react@17.0.0" in deno.json or package.json, the filter "foobar" would update npm:react to the latest version.

deno update --latest foobar

Filters can be combined, and negative filters can be used to exclude results:

deno update --latest "@std/*" "!@std/fmt*"

Specific version requirements to update to can be specified:

deno update @std/fmt@^1.0.2

Options Jump to heading

--compatible
Jump to heading

Only consider versions that satisfy semver requirements.

--env-file<FILE>optional
Jump to heading

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.

--interactive, -i
Jump to heading

Interactively select which dependencies to update.

Consider the latest version, regardless of semver constraints.

--lockfile-only
Jump to heading

Install only updating the lockfile.

--minimum-dependency-age<minimum-dependency-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).

--recursive, -r
Jump to heading

Include all workspace members.

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.

Did you find what you needed?

编辑此页面
Privacy policy