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] : When a specified package is only a name then the latest patching version of this package will be upgraded to.

[package@tag] : When a specified package contains a tag then the specified tag will be upgraded to. 標籤的名字是由專案開發者決定的,通常你使用這個命來來安裝實驗性的版本或長期支援的版本, 你使用的標籤會做為版本號出現在你的 package.json 中。

[package@version] : When a specified package contains a version then the specified version will be upgraded to. The package.json dependency reference will also be changed to match this specified version. You can use any SemVer version number or range.

--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> 將升级所有符合此模式的套件。

例如:

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