Skip to main content
On this page

deno outdated

检查过期依赖 Jump to heading

outdated 子命令会检查 deno.jsonpackage.json 文件中列出的 NPM 和 JSR 依赖是否有新版本,并显示可以更新的依赖。 工作区也完全受支持,包括部分成员使用 package.json、其他成员使用 deno.json 的工作区。

例如,考虑一个包含 deno.json 文件的项目:

deno.json
{
  "imports": {
    "@std/fmt": "jsr:@std/fmt@^1.0.0",
    "@std/async": "jsr:@std/async@1.0.1",
    "chalk": "npm:chalk@4"
  }
}

以及一个将 @std/fmt 锁定为 1.0.0 的锁定文件。

>_
deno outdated
┌────────────────┬─────────┬────────┬────────┐
│ 包名称          │ 当前版本  │ 更新版本  │ 最新版本  │
├────────────────┼─────────┼────────┼────────┤
│ jsr:@std/fmt   │ 1.0.0   │ 1.0.3  │ 1.0.3  │
├────────────────┼─────────┼────────┼────────┤
│ jsr:@std/async │ 1.0.1   │ 1.0.1  │ 1.0.8  │
├────────────────┼─────────┼────────┼────────┤
│ npm:chalk      │ 4.1.2   │ 4.1.2  │ 5.3.0  │
└────────────────┴─────────┴────────┴────────┘

更新版本 列显示最新的 semver 兼容版本,而 最新版本 列显示最新版本。

注意,尽管没有可以更新到的 semver 兼容版本,jsr:@std/async 仍然被列出。如果您希望仅显示具有新兼容版本的包,可以传递 --compatible 标志。

>_
deno outdated --compatible
┌────────────────┬─────────┬────────┬────────┐
│ 包名称          │ 当前版本  │ 更新版本  │ 最新版本  │
├────────────────┼─────────┼────────┼────────┤
│ jsr:@std/fmt   │ 1.0.0   │ 1.0.3  │ 1.0.3  │
└────────────────┴─────────┴────────┴────────┘

jsr:@std/fmt 仍然被列出,因为它可以安全地更新到 1.0.3,但 jsr:@std/async 不再显示。

更新依赖 Jump to heading

outdated 子命令还可以通过 --update 标志更新依赖。 默认情况下,它只会将依赖更新到 semver 兼容版本(即不会更新到不兼容的版本)。

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

要更新到最新版本(无论是否兼容 semver),请传递 --latest 标志。

>_
deno outdated --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

outdated 子命令也支持选择要操作的包。 这在使用或不使用 --update 标志时都适用。

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

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

例如,要更新所有具有 @std 范围的包,除了 @std/fmt

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

请注意,如果您使用通配符,您可能需要用引号将参数包围,以防止 shell 尝试展开它们。

更新到特定版本 Jump to heading

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

>_
deno outdated --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

在工作区设置中,默认情况下,outdated 只会在 当前 工作区成员上操作。

例如,给定一个工作区:

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

./member-a 目录运行

>_
deno outdated

将仅检查 ./member-a/deno.json./member-a/package.json 中列出的过期依赖。

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

>_
deno outdated --recursive
deno outdated --update --latest -r

Options Jump to heading

--compatible Jump to heading

Only consider versions that satisfy semver requirements.

--interactive Jump to heading

Short flag: -i

Interactively select which dependencies to update.

--latest Jump to heading

Consider the latest version, regardless of semver constraints.

--lockfile-only Jump to heading

Install only updating the lockfile.

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

Short flag: -r

Include all workspace members.

--update Jump to heading

Short flag: -u

Update dependency versions.

Dependency management options Jump to heading

--frozen Jump to heading

Error out if lockfile is out of date.

--lock Jump to heading

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

--no-lock Jump to heading

Disable auto discovery of the lock file.

Last updated on

你找到了你需要的东西吗?

编辑此页面
隐私政策