Yarn 1 entered maintenance mode in January 2020 and is effectively dead. Upgrading production Next.js repos to Yarn 4 roughly cut our install times in half (yarn install --immutable dropped from ~1m 45s to ~47s, and parallel multi-service builds fell from ~3m 52s to ~1m 58s).

Key migration steps

  1. Keep nodeLinker: node-modules first: Set nodeLinker: node-modules and enableTelemetry: false in .yarnrc.yml so Docker builds, debuggers, and Next.js tooling keep working predictably before you ever consider Plug'n'Play.
  2. Pin via Corepack: Run yarn set version 4.6.0 so package.json records "packageManager": "yarn@4.6.0".
  3. Update .gitignore and .dockerignore: Ignore .yarn and node_modules so native host installs and Docker containers can live side by side.
  4. Enable Corepack in Docker and CI: Replace old apt Yarn 1 installs with corepack enable && corepack prepare yarn@4.6.0 in base images, and add corepack enable to CI jobs using stock Node images. Yarn 4 parallelizes harder too, so yarn install jobs may need higher CI memory limits.

CLI surprises coming from Yarn 1

  • Upgrading packages: yarn up <pkg> jumps to the latest major (for example bumping next from 14 to 16), while yarn up -R <pkg> acts like Yarn 1's yarn upgrade and stays within the semver range. Plain yarn updates lockfile patches within ranges.
  • yarn link changed completely: Instead of running yarn link in the package and yarn link @scope/pkg in the app, Yarn 4 takes relative paths directly (yarn link ../pkg-one ../pkg-two). It also writes portal: resolutions into package.json and yarn.lock, which is annoying because you have to be careful not to commit those local edits.
  • Stricter dependency resolution: Yarn 4 catches missing peer and dev dependencies (like explicit react-is or aligned react and react-dom versions) that Yarn 1 silently hoisted.