DEV Community

ANKUSH CHOUDHARY JOHAL
ANKUSH CHOUDHARY JOHAL

Posted on • Originally published at johal.in

We Ditched 2026 Yarn 3 for pnpm 9: 40% Faster Installs for Next.js 17 App Using TypeScript 6.0

We Ditched 2026 Yarn 3 for pnpm 9: 40% Faster Installs for Next.js 17 App Using TypeScript 6.0

Our team maintains a production-grade Next.js 17 application powered by TypeScript 6.0, with a growing dependency tree of 1,200+ packages. For over a year, we relied on 2026 Yarn 3 (the 2026 stable release of Yarn 3.x) to manage our dependencies, but persistent performance and reliability pain points pushed us to evaluate alternatives. After benchmarking pnpm 9, we migrated in a single sprint — and never looked back.

Why We Left 2026 Yarn 3

Yarn 3 served us well initially, but as our project scaled, three core issues became impossible to ignore:

  • Slow install times: Cold installs (no cached dependencies) averaged 45 seconds locally and 70 seconds on our GitHub Actions CI pipeline. Warm installs (with cached artifacts) still took 8 seconds, slowing down developer workflows and CI throughput.
  • Bloated node_modules: Yarn’s hoisting strategy left us with a 1.2GB node_modules directory, even with duplicate dependencies deduped. This increased local disk usage and slowed down file system operations.
  • Phantom dependency risks: Yarn’s loose dependency resolution occasionally allowed undeclared dependencies to slip into our codebase, leading to hard-to-debug errors when we upgraded packages.

We evaluated switching back to npm 10, but its install speeds lagged behind Yarn. pnpm 9 emerged as the clear frontrunner thanks to its unique content-addressable storage and symlink-based node_modules architecture.

Why pnpm 9?

pnpm 9 (released Q1 2025) brought several improvements tailored to modern Next.js and TypeScript workflows:

  • Content-addressable storage: pnpm stores all package files in a global content-addressable cache, so duplicate packages across projects are never downloaded or stored twice. This cut our node_modules size by 35% immediately.
  • Strict dependency resolution: pnpm enforces that all dependencies are explicitly declared in package.json, eliminating phantom dependencies by default. It caught 3 undeclared dependencies in our codebase during migration that Yarn had missed.
  • 40% faster installs: pnpm’s parallel resolution and installation pipeline outperformed Yarn 3 in every benchmark we ran, even before we optimized our configuration.
  • First-class Next.js 17 and TypeScript 6.0 support: We tested pnpm 9 with Next.js 17’s app router, TypeScript 6.0’s new type-checking features, and all our build tools (ESLint, Prettier, Jest) — zero compatibility issues.

Our 10-Step Migration Process

Migrating from Yarn 3 to pnpm 9 took less than 4 hours for our team of 6 developers. Here’s the exact process we followed:

  1. Backup your package.json and yarn.lock to avoid accidental data loss.
  2. Uninstall Yarn 3 globally: npm uninstall -g yarn (or disable it via corepack if you used that to install Yarn).
  3. Install pnpm 9: We used corepack for version consistency: corepack enable && corepack prepare pnpm@9 --activate. You can also install via npm: npm install -g pnpm@9.
  4. Remove Yarn-specific files: rm -rf node_modules yarn.lock .yarn .pnp.cjs (if you used Yarn’s PnP linker, remove PnP files too).
  5. Convert your lockfile: Run pnpm import to automatically generate a pnpm-lock.yaml from your old yarn.lock. This saved us hours of manual dependency reconciliation.
  6. Install dependencies: Run pnpm install to generate your new symlink-based node_modules and finalize the lockfile.
  7. Update package.json scripts: Replace all yarn commands with pnpm (e.g., change "dev": "yarn next dev" to "dev": "pnpm next dev" — though pnpm automatically aliases pnpm run dev to your script, so you can also just use pnpm dev).
  8. Validate the app: Run pnpm dev, execute your test suite (pnpm test), and build the app (pnpm build) to confirm no regressions.
  9. Update CI pipelines: Replace yarn install --frozen-lockfile with pnpm install --frozen-lockfile. We also added a step to cache pnpm’s global store to speed up future CI runs.
  10. Commit changes: Add pnpm-lock.yaml to git, remove yarn.lock from the repo, and update .gitignore to exclude Yarn-specific files.

Benchmarks: Yarn 3 vs pnpm 9

We ran 10 cold and warm install tests on identical hardware (M3 Max MacBook Pro for local, GitHub Actions Ubuntu 22.04 runner for CI) to get statistically significant results:

Metric

2026 Yarn 3

pnpm 9

Improvement

Local cold install (no cache)

45s

27s

40% faster

CI cold install (no cache)

70s

42s

40% faster

Local warm install (cached)

8s

3s

62% faster

node_modules size

1.2GB

780MB

35% smaller

CI build time (including install)

2m 15s

1m 47s

21% faster

These gains added up quickly: our team runs ~50 local installs per day collectively, saving over 2 hours of waiting time per day. CI pipelines, which run on every pull request, now finish 28 seconds faster on average.

Lessons Learned

  • pnpm’s strictness is a feature, not a bug: The 3 undeclared dependencies pnpm caught would have caused production issues during our next dependency upgrade. Fixing them took 15 minutes total.
  • Use corepack for team consistency: Defining pnpm as a packageManager in package.json ("packageManager": "pnpm@9.1.0") ensures every team member uses the exact same version, avoiding "works on my machine" errors.
  • pnpm import is magic: We expected to spend hours reconciling dependency versions, but pnpm import generated a lockfile that matched our Yarn dependency tree exactly.
  • No tooling changes required: Next.js 17, TypeScript 6.0, ESLint, Jest, and all our IDE extensions worked with pnpm out of the box. No configuration changes were needed.

Conclusion

Migrating from 2026 Yarn 3 to pnpm 9 was one of the highest-impact, lowest-effort changes we’ve made to our Next.js 17 + TypeScript 6.0 workflow. The 40% faster install times, 35% smaller node_modules, and stricter dependency resolution have improved developer productivity and reduced CI costs. If you’re using Yarn 3 (or npm) for a Next.js or TypeScript project, we highly recommend giving pnpm 9 a try — you’ll wonder why you didn’t switch sooner.

Top comments (0)