• yarn upgrade [package | package@tag | package@version | @scope/]… [—ignore-engines] [—pattern]
  • yarn upgrade [package]… —latest|-L [—caret | —tilde | —exact] [—pattern]
  • yarn upgrade (—scope|-S) @scope [—latest] [—pattern]

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

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

    该命令会根据在 package.json 文件中所指定的版本范围将依赖更新到其最新版本。也会重新生成yarn.lock 文件。

    可以选择指定一个或多个包名称。指定包名称时,将只升级这些包。未指定包名称时,将升级所有依赖项。

    [package] : When a specified package is only a name then the latest patching version of this package will be upgraded to.

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

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

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

    示例:

    1. yarn upgrade
    2. yarn upgrade left-pad
    3. yarn upgrade left-pad@^1.0.0
    4. yarn upgrade left-pad grunt
    5. yarn upgrade @angular

    yarn upgrade —pattern <pattern> 将升级所有匹配此模式的包。

    示例:

    1. yarn upgrade --pattern gulp
    2. yarn upgrade left-pad --pattern "gulp|grunt"
    3. 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. 否则,它将被更改为插入符号 (^)。 One of the flags —caret, —tilde or —exact can be used to explicitely specify a range.

    示例:

    1. yarn upgrade --latest
    2. yarn upgrade left-pad --latest
    3. yarn upgrade left-pad grunt --latest --tilde
    yarn upgrade (—scope|-S) @scope [—latest] [—pattern]

    —作用域 @scope/: 指定作用域时, 只会升级以作用域开头的包。作用域必须以 “@” 开头。

    —latest : 忽略在 package.json 中指定的版本范围。 Instead, the version specified by the latest tag will be used (potentially upgrading the packages across major versions).

    示例:

    1. yarn upgrade --scope @angular
    2. yarn upgrade -S @angular

    原文: https://yarnpkg.com/zh-Hans/docs/cli/upgrade