pnpm update
别名:up,upgrade
🌐 Aliases: up, upgrade
pnpm update 根据指定的范围将软件包更新到最新版本。
当不带参数使用时,更新所有依赖。
🌐 When used without arguments, updates all dependencies.
长话短说
🌐 TL;DR
| 命令 | 含义 |
|---|---|
pnpm up | 更新所有依赖,遵循 package.json 中指定的范围 |
pnpm up --latest | 将所有依赖更新到最新版本 |
pnpm up foo@2 | 将 foo 更新到 v2 上的最新版本 |
pnpm up "@babel/*" | 更新 @babel 范围下的所有依赖 |
选择具有模式的依赖
🌐 Selecting dependencies with patterns
你可以使用模式来更新特定的依赖。
🌐 You can use patterns to update specific dependencies.
更新所有 babel 包:
🌐 Update all babel packages:
pnpm update "@babel/*"
更新所有依赖,除了 webpack:
🌐 Update all dependencies, except webpack:
pnpm update "\!webpack"
模式也可以组合使用,因此下一个命令将更新所有 babel 软件包,除了 core:
🌐 Patterns may also be combined, so the next command will update all babel packages, except core:
pnpm update "@babel/*" "\!@babel/core"
选项
🌐 Options
--recursive, -r
在所有包含 package.json 的子目录中同时运行更新(不包括 node_modules)。
🌐 Concurrently runs update in all subdirectories with a package.json (excluding
node_modules).
用法示例:
🌐 Usage examples:
pnpm --recursive update
# updates all packages up to 100 subdirectories in depth
pnpm --recursive update --depth 100
# update typescript to the latest version in every package
pnpm --recursive update typescript@latest
--latest, -L
将依赖更新到其 latest 标签指定的最新稳定版本(可能会跨主要版本升级包),只要 package.json 中指定的版本范围低于 latest 标签(即不会降级预发布版本)。
🌐 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
更新全局包。
🌐 Update global packages.
--workspace
尝试链接工作区中的所有包。版本将更新以匹配工作区内包的版本。
🌐 Tries to link all packages from the workspace. Versions are updated to match the versions of packages inside the workspace.
如果特定的软件包被更新,如果更新后的依赖中有任何未在工作区中找到,该命令将执行失败。例如,如果 express 不是工作区软件包,则以下命令将失败:
🌐 If specific packages are updated, the command will fail if any of the updated
dependencies are not found inside the workspace. For instance, the following
command fails if express is not a workspace package:
pnpm up -r --workspace express
--prod, -P
只更新 dependencies 和 optionalDependencies 中的包。
🌐 Only update packages in dependencies and optionalDependencies.
--dev, -D
只更新 devDependencies 中的软件包。
🌐 Only update packages in devDependencies.
--no-optional
不要在 optionalDependencies 中更新软件包。
🌐 Don't update packages in optionalDependencies.
--interactive, -i
显示过时的依赖并选择要更新的依赖。
🌐 Show outdated dependencies and select which ones to update.
--no-save
不要更新 package.json 中的范围。
🌐 Don't update the ranges in package.json.