pnpm error ERR_PNPM_OUTDATED_LOCKFILE after node version switch
Fixes pnpm ERR_PNPM_OUTDATED_LOCKFILE after switching Node versions. Use it when pnpm install refuses to run because the lockfile was written by a different pnpm major version than the one now on PATH. Key trigger: the error names ERR_PNPM_OUTDATED_LOCKFILE right after a Node version switch.
pnpm error ERRPNPMOUTDATED_LOCKFILE after node version switch
TL;DR: Your lockfile was written by a different pnpm major version than the one now installed. Either switch back to the pinned pnpm via corepack, or regenerate the lockfile with pnpm install. The error is pnpm refusing to trust a lockfile format it does not understand - not a broken project.
pnpm error ERR_PNPM_OUTDATED_LOCKFILE after node version switchSteps
Confirm the mismatch. Run
pnpm --versionand check thelockfileVersionline at the top ofpnpm-lock.yaml. Expected: the installed pnpm major and the lockfile version belong to different pnpm majors (for example pnpm 10 installed but the lockfile says 9.0).If the project pins pnpm in the
packageManagerfield of package.json, runcorepack enableand then re-run your install command. Corepack shims the pinned pnpm version automatically. Expected:pnpm --versionnow shows the pinned version and the install proceeds.Otherwise regenerate the lockfile with the current pnpm: run
pnpm install(without--frozen-lockfile). Expected: pnpm rewritespnpm-lock.yamland completes the install with no ERRPNPMOUTDATED_LOCKFILE.Verify the tree is stable: run
pnpm install --frozen-lockfile. Expected: it completes cleanly, proving the lockfile now matches the installed pnpm.If this broke in CI, pin the pnpm version in the workflow (via corepack or the setup action's version input) so the runner always matches the lockfile. Expected: CI installs succeed on every run, not just on your machine.
Use this when
pnpm installfails with ERRPNPMOUTDATED_LOCKFILE right afternvm use, a Node upgrade, or a corepack change.- The
lockfileVersioninpnpm-lock.yamldoes not match the installed pnpm major. - A teammate's machine installs fine but yours does not (different pnpm on PATH).
Not for this skill when
- The error comes from npm or yarn - different package managers, different lockfile errors.
- pnpm versions already match and the lockfile is just stale - then plain
pnpm installis the whole fix. - The error is
Cannot install with "frozen-lockfile"- that is a lockfile/content mismatch, not a version mismatch.
Variant phrasings
- pnpm install fails with outdated lockfile after nvm use
- pnpm lockfileVersion mismatch between pnpm 9 and pnpm 10
- ERRPNPMOUTDATED_LOCKFILE when switching node versions
Why it happens
pnpm bumps its lockfile format between major versions. Switching Node with nvm (or a corepack update) can silently change which pnpm major is on PATH, so the pnpm now running cannot vouch for the lockfile the old pnpm wrote - and it fails loudly instead of guessing.
Edge cases
- Regenerating the lockfile can shift transitive dependency versions - review the
pnpm-lock.yamldiff before committing. - Corepack's pnpm shim is per Node version, so re-check after every Node switch, not just the first one.
- If the repo has no pinned pnpm version, add one via the
packageManagerfield so the whole team (and CI) converges.
Provenance
Resolved from the public thread: https://vectle.com/posts/pstnc-uHCnPrvVbPaovGYBGQ