yarn up — Yarn CLI reference

Update dependencies to the latest versions

Docs/Reference/CLI/up

yarn up

Update dependencies to the latest versions

yarn up <DESCRIPTORS…>

This command upgrades the dependencies matching the specified descriptors, wherever the project declares them: in the dependencies, devDependencies and optionalDependencies of its workspaces, and in the workspace profiles (workspaceProfiles) of its .yarnrc.yml. peerDependencies are left unchanged. The command fails if one of the descriptors doesn’t match any of those declarations.

The entries of the catalogs (catalog, catalogs) are only upgraded on request, one catalog at a time: --catalog upgrades the matching entries of the default catalog, and --catalog=<name> those of the named one. Nothing but that catalog is modified then. The name has to be attached to the option with =: yarn up --catalog react upgrades the react entry of the default catalog.

What a declaration becomes depends on the range it’s currently declared with:

  • A descriptor that is only a package name (yarn up lodash) moves the declaration to the latest release of the package it points to: on the npm registry for semver ranges and tags (including npm: aliases, which keep pointing to the same package), on JSR for jsr: ranges, and among the Node.js distributions for builtin: ranges. Declarations that don’t have a latest release to go to (workspace:, git repositories, URLs, file:, link:, portal:, exec:) keep their range and are resolved again.

  • A descriptor with a bare semver range or tag (yarn up lodash@^4.17.0) selects other versions of the package the declaration points to: an alias keeps its target (npm:other@^4.17.0), and jsr:, builtin: and workspace: ranges keep their protocol (workspace:^4.17.0). Declarations that don’t have versions to select from (git repositories, URLs, file:, link:, portal:, exec:) are replaced by the range.

  • A descriptor whose range names its protocol (npm:, jsr:, workspace:, a git repository, a path, …) says where the package must come from, and replaces the declared range whatever it was.

  • patch: ranges keep their patch in all those cases: the rules above apply to the package the patch is applied to. Only a patch: range replaces them. If the patch doesn’t apply to the new version, the install fails just like it does for any patch that doesn’t apply.

  • catalog: references are left untouched: the range they stand for is the entry of the catalog, which only --catalog upgrades (following the same rules, according to the range of the entry). Only another catalog: reference replaces them. A descriptor that only matches catalog: references is an error that tells which catalog to upgrade.

The lockfile always ends up on the best match for the resulting ranges, including when they’re the same as before.

The manifests and the configuration file are updated before running the install. If the install fails before the lockfile is updated (for example because a package can’t be resolved), they are restored to what they were before the command.

If -R,--recursive is set, Yarn refreshes all lockfile resolutions matching the selected packages without editing manifests. Depending on the goal, you may want to run both yarn up and yarn up -R. Since it doesn’t edit anything, -R,--recursive can’t be used with --catalog; the other options apply to catalog entries like they do to any other declaration.

The -C,--caret, -E,--exact, and -T,--tilde options have the same meaning as in yarn add: they choose the range modifier used when the requested descriptor has no explicit range or uses a tag.

If the --mode=<mode> option is set, Yarn will change which artifacts are generated. The modes currently supported are:

  • skip-build will not run the build scripts at all. Note that this is different from setting enableScripts to false because the latter will disable build scripts, and thus affect the content of the artifacts generated on disk, whereas the former will just disable the build step but not the scripts themselves, which just won’t run.

  • update-lockfile will skip the link step altogether, and only fetch packages that are missing from the lockfile (or that have no associated checksums). This mode is typically used by tools like Renovate or Dependabot to keep a lockfile up-to-date without incurring the full install cost.

You can think of yarn up as the Yarn 6 counterpart to yarn upgrade --latest in Yarn 1: it ignores the ranges previously listed in your manifests. Unlike yarn upgrade, which only upgraded dependencies in the current workspace, yarn up upgrades all workspaces at the same time.

This command accepts glob patterns as arguments (if valid Descriptors and supported by micromatch). Make sure to escape the patterns, to prevent your own shell from trying to expand them.

Note: The ranges have to be static, only the package scopes and names can contain glob patterns.

#--fixed, -Fboolean

Store dependency tags as-is instead of resolving them to versions

#--exact, -Eboolean

Use an exact semver range for resolved versions

#--tilde, -Tboolean

Use the ~ semver modifier on the resolved range

#--caret, -Cboolean

Use the ^ semver modifier on the resolved range

#--recursive, -Rboolean

Refresh matching lockfile resolutions without editing manifests

#--catalogstring

Upgrade the entries of a catalog (the default one unless a name is given as --catalog=<name>) rather than the other declarations

#--no-time-gateboolean

Disable the minimum release age check for this command

#--modeboolean

Select which install artifacts Yarn should generate

Examples#

Upgrade all instances of lodash to the latest release

yarn up lodash

Upgrade all instances of lodash to 4.17.21

yarn up lodash@4.17.21

Upgrade all instances of packages with the @babel scope to the latest release

yarn up '@babel/*'

Refresh the lockfile resolutions of lodash without changing the manifests

yarn up -R lodash

Upgrade the lodash entry of the default catalog to the latest release

yarn up --catalog lodash

Upgrade all the entries of the catalog named tooling

yarn up --catalog=tooling '*'