vercel: unexpected `ERR_PNPM_OUTDATED_LOCKFILE` error
https://vercel.com/jounqin/prettier/BH8R7dVznV3PbCuN9jnofJDYQ5Be
21:51:55.732 | Lockfile is up-to-date, resolution step is skipped
21:51:55.736 | ERR_PNPM_OUTDATED_LOCKFILE Cannot install with "frozen-lockfile" because pnpm-lock.yaml is not up-to-date with packages/pkg/package.json
The first line says Lockfile is up-to-date, and then it just fails.
pnpm version: 7.6.0 and 7.7.0
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 1
- Comments: 17 (5 by maintainers)
Commits related to this issue
- Add pnpm strict config to try to solve out of date lockfile issue https://github.com/vercel/vercel/issues/8272\#issuecomment-1209936567 — committed to mehulkar/mehulkar.com by mehulkar a year ago
you might have solved it, but just in case someone else faces it.
Run the command
pnpm install --fix-lockfile, and you should notice changes in your lockfile....in its corner and ‘Inpect deployment’ --> And you’ll get the following ‘Building’ log :pnpm install --no-frozen-lockfilefor deployment.installcommand so override the ‘Install Command’ in settings and not the ‘Build Command’.This is not a problem linked with vercel but I know the fix for this.
This is happening because the lock-file is not up-to-date and you are trying to install packages with
frozen-lockfileflag turned on. It is turned on by default, you can switch off by doing this:ENABLE_EXPERIMENTAL_COREPACK=1environment setting on the Vercel project does the trick for me. So closing.I’m on Mac.
I solved my issue: It’s due to a pnpm quirk, that pnpm update can result with pnpm-lock.yaml definitions that’s newer than what’s specified in package.json. If I add
strict-peer-dependencies=falseto .npmrc file however and re-run pnpm update, package.json would have version updated and inlined with pnpm-lock.yaml.Vercel CI then builds without complaint.
Can’t say it’s not a Vercel/CI env specific bug however, since I can run on local pnpm i and pnpm i --frozen-lockfile fine regardless.
Doing this worked for me:
pnpm install --no-frozen-lockfileThis error happens when you have
.npmrcin your HOME directory with values such asauto-install-peers=truebecause your Vercel deployment won’t know about those local settings.To solve this problem, you can commit your
.npmrcto your repository (assuming you don’t have any secrets in there) so that Vercel as well as other members of your team can use the same pnpm settings.Also note that
~/.npmrcin your home directory will impact all installs on your machine so its best deletestrict-peer-dependencies,auto-install-peers, etc from there and put those settings in the project directory (again so they can be shared by members of your team and Vercel deployments)Please try out corepack https://vercel.com/changelog/corepack-experimental-is-now-available
It lets you select your pnpm version which should solve this issue, thanks!
Thanks for putting the actual fix for this. In my case I had edited
package.json(I moved some packages from dev dependencies to dependencies) and I committed to Git. Vercel was (rightfully) giving me the error.Same error still reproducible with my repo. From Vercel deploy:
On my local, both
pnpm iandpnpm i --frozen-lockfileruns without issue. I’ve runpnpm upbefore so pnpm-lock.yaml not being up to date is false.I run
pnpmjust successfully, maybe the pnpm version is not always latest on Vercel’s environment.