跳到主内容
版本:9.x

pnpm update

Aliases: up, upgrade

pnpm update updates packages to their latest version based on the specified range.

在不带参数的情况下使用时,将更新所有依赖关系。

摘要:

CommandMeaning
pnpm upUpdates all dependencies, adhering to ranges specified in package.json
pnpm up --latest将所有依赖项更新到最新版本
pnpm up foo@2Updates foo to the latest version on v2
pnpm up "@babel/*"Updates all dependencies under the @babel scope

使用模式匹配选择依赖项

您可以使用 Pattern 来更新特定的依赖项。

Update all babel packages:

pnpm update "@babel/*"

Update all dependencies, except webpack:

pnpm update "\!webpack"

Patterns may also be combined, so the next command will update all babel packages, except core:

pnpm update "@babel/*" "\!@babel/core"

配置项

--recursive, -r

Concurrently runs update in all subdirectories with a package.json (excluding node_modules).

用法示例:

pnpm --recursive update
# 更新子目录深度为 100 以内的所有包
pnpm --recursive update --depth 100
# 将每个包中的 typescript 更新为最新版本
pnpm --recursive update typescript@latest

--latest, -L

Update the dependencies to their latest stable version as determined by their latest tags (potentially upgrading the packages across major versions) as long as the version range specified in package.json is lower than the latest tag (i.e. it will not downgrade prereleases).

--global, -g

更新全局安装的依赖包。

--workspace

尝试链接工作区中所有的包。 版本将更新至与工作区内的包匹配的版本。

如果更新了特定的包,而在工作区内也找不到任何可更新的 依赖项,则命令将会失败。 For instance, the following command fails if express is not a workspace package:

pnpm up -r --workspace express

--prod, -P

Only update packages in dependencies and optionalDependencies.

--dev, -D

Only update packages in devDependencies.

--no-optional

Don't update packages in optionalDependencies.

--interactive, -i

显示过时的依赖项并选择要更新的依赖项。

--filter <package_selector>

Read more about filtering.