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 interactivelyCommon 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
yarn install: Usage, Options & Common CI Errorsyarn install resolves and installs dependencies from yarn.lock. Usage, the --immutable / --frozen-lockfile CI…
yarn "Your lockfile needs to be updated" (--frozen-lockfile) - Fix in CIFix yarn "Your lockfile needs to be updated" under --frozen-lockfile / --immutable in CI - package.json chang…
npm update: Usage, Options & Common Errorsnpm update upgrades dependencies within their semver ranges and rewrites the lockfile. Usage, what it will an…