deno outdated
检查过期依赖 Jump to heading
outdated 子命令会检查 deno.json 或 package.json
文件中列出的 NPM 和 JSR 依赖是否有新版本,并显示可以更新的依赖。
工作区也完全受支持,包括部分成员使用 package.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 只会在 当前 工作区成员上操作。
例如,给定一个工作区:
{
"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
deno outdated [OPTIONS] [filters]...Find and update outdated dependencies. By default, outdated dependencies are only displayed.
Display outdated dependencies:
deno outdated
deno outdated --compatible
Update dependencies to the latest semver compatible versions:
deno outdated --update
Update dependencies to the latest versions, ignoring semver requirements:
deno outdated --update --latest
Update dependencies within their existing version ranges, without editing deno.json / package.json (like npm update):
deno outdated --update --lockfile-only
Filters can be used to select which packages to act on. Filters can include wildcards (*) to match multiple packages.
deno outdated --update --latest "@std/*"
deno outdated --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 outdated --update --latest foobar
Filters can be combined, and negative filters can be used to exclude results:
deno outdated --update --latest "@std/*" "!@std/fmt*"
Specific version requirements to update to can be specified:
deno outdated --update @std/fmt@^1.0.2
Options Jump to heading
--compatibleOnly consider versions that satisfy semver requirements.
--env-file<FILE>optionalLoad 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, -iInteractively select which dependencies to update.
--latestConsider the latest version, regardless of semver constraints.
--lockfile-onlyInstall 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).
--recursive, -rInclude all workspace members.
--update, -uUpdate dependency versions.
Dependency management options Jump to heading
--frozen<BOOLEAN>optionalError out if lockfile is out of date.
--lock<FILE>optionalCheck the specified lock file. (If value is not provided, defaults to "./deno.lock").
--no-lockDisable auto discovery of the lock file.