yarn upgrade

升级包到它们基于规范范围的最新版本。

yarn upgrade [package | package@tag | package@version | @scope/]... [--ignore-engines] [--pattern]

This command updates dependencies to their latest version based on the version range specified in the package.json file. The yarn.lock file will be recreated as well.

Optionally, one or more package names can be specified. When package names are specified, only those packages will be upgraded. When no package names are specified, all dependencies will be upgraded.

[package] : 仅指定包名称时,将升级到此包的最新补丁版本。

[package@tag] : 指定包包含标签时,将升级到该标签的版本。 标签 名称由项目维护者选择,通常你用这个命令来安装一个活跃开发中的包的实验版本或长期支持版本。 你选择的标签会成为出现在你的 package.json 文件里的版本。

[package@version] : 当指定包包含版本时,将升级到该版本。 package.json 中指明的依赖也将同时更改为指定的版本。 你可以使用任何语义版本的版本号或版本范围。

--ignore-engines : 此标志可用于跳过引擎检查。

示例:

yarn upgrade
yarn upgrade left-pad
yarn upgrade left-pad@^1.0.0
yarn upgrade left-pad grunt
yarn upgrade @angular

yarn upgrade --pattern <pattern> will upgrade all packages that match the pattern.

示例:

yarn upgrade --pattern gulp
yarn upgrade left-pad --pattern "gulp|grunt"
yarn upgrade --latest --pattern "gulp-(match|newer)"
yarn upgrade [package]... --latest|-L [--caret | --tilde | --exact] [--pattern]

The upgrade --latest command upgrades packages the same as the upgrade command, but ignores the version range specified in package.json. Instead, the version specified by the latest tag will be used (potentially upgrading the packages across major versions).

The package.json file will be updated to reflect the latest version range. By default, the existing range specifier in package.json will be reused if it is one of: ^, ~, <=, >, or an exact version. Otherwise, it will be changed to a caret (^). One of the flags --caret, --tilde or --exact can be used to explicitely specify a range.

示例:

yarn upgrade --latest
yarn upgrade left-pad --latest
yarn upgrade left-pad grunt --latest --tilde
yarn upgrade (--scope|-S) @scope [--latest] [--pattern]

--scope @scope/ : When a scope is specified, only packages that begin with that scope will be upgraded. A scope must begin with ‘@’.

--latest : Ignores the version range specified in package.json. Instead, the version specified by the latest tag will be used (potentially upgrading the packages across major versions).

示例:

yarn upgrade --scope @angular
yarn upgrade -S @angular