Skip to content
Latchkey

yarn upgrade / yarn up: Usage & Common Errors

Upgrade dependencies and update yarn.lock.

yarn upgrade (Yarn 1) and yarn up (Yarn 2+/Berry) raise installed dependencies to newer versions and rewrite yarn.lock.

What it does

With no args, Yarn 1 yarn upgrade bumps every dependency to the latest in-range version. Berry uses yarn up <pkg> to upgrade specific packages (and can cross ranges, updating package.json). Both rewrite yarn.lock.

Common usage

Terminal
yarn upgrade                    # Yarn 1: all in-range
yarn upgrade lodash@^4.17.21    # Yarn 1: target a range
yarn up react react-dom         # Berry: upgrade specific pkgs
yarn upgrade-interactive        # pick upgrades interactively

Common CI gotcha: upgrade rewrites the lockfile

Running an upgrade in CI changes yarn.lock and then conflicts with the next immutable install. Do upgrades locally, review and commit the new yarn.lock, and keep CI on yarn install --immutable.

Terminal
# locally:
yarn up react && git add yarn.lock package.json && git commit -m "deps"

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →