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

Most upvoted comments

@haneenmahd

The first line says Lockfile is up-to-date, and then it just fails.

And I install successfully locally, so it must be something wrong on Vercel’s building progress.

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.

  • Go to your application in vercel --> Deployments tab --> Latest deployment listed with red dot error --> Click the 3 dots ... in its corner and ‘Inpect deployment’ --> And you’ll get the following ‘Building’ log :
Running "vercel build"

Vercel CLI 31.1.1

Detected `pnpm-lock.yaml` version 6 generated by pnpm 8...

Installing dependencies...

 ERR_PNPM_OUTDATED_LOCKFILE  Cannot install with "frozen-lockfile" because pnpm-lock.yaml is not up to date with package.json

Note that in CI environments this setting is true by default. If you still need to run install in such cases, use "pnpm install --no-frozen-lockfile"

    Failure reason:
    specifiers in the lockfile ({"react":"^18.2.0","react-dom":"^18.2.0","react-hook-form":"^7.45.2","react-icons":"^4.10.1","react-router-dom":"^6.14.1","@types/react":"^18.2.14","@types/react-dom":"^18.2.6","@vitejs/plugin-react":"^4.0.1","autoprefixer":"^10.4.14","daisyui":"^3.2.1","eslint":"^8.44.0","eslint-config-airbnb":"^19.0.4","eslint-plugin-import":"^2.27.5","eslint-plugin-jsx-a11y":"^6.7.1","eslint-plugin-react":"^7.32.2","eslint-plugin-react-hooks":"^4.6.0","eslint-plugin-react-refresh":"^0.4.1","postcss":"^8.4.25","tailwind-scrollbar":"^3.0.4","tailwindcss":"^3.3.2","vite":"^4.4.0"}) don't match specs in package.json ({"@types/react":"^18.2.14","@types/react-dom":"^18.2.6","@vitejs/plugin-react":"^4.0.1","autoprefixer":"^10.4.14","daisyui":"^3.2.1","eslint":"^8.44.0","eslint-config-airbnb":"^19.0.4","eslint-plugin-import":"^2.27.5","eslint-plugin-jsx-a11y":"^6.7.1","eslint-plugin-react":"^7.32.2","eslint-plugin-react-hooks":"^4.6.0","eslint-plugin-react-refresh":"^0.4.1","postcss":"^8.4.25","tailwind-scrollbar":"^3.0.4","tailwindcss":"^3.3.2","vite":"^4.4.0","react":"^18.2.0","react-dom":"^18.2.0","react-hook-form":"^7.45.2","react-icons":"^4.10.1","react-router-dom":"^6.14.1","tw-elements":"^1.0.0-beta2"})
Error: Command "pnpm install" exited with 1
  • Now look carefully at these 2 lines :
 ERR_PNPM_OUTDATED_LOCKFILE  Cannot install with "frozen-lockfile" because pnpm-lock.yaml is not up to date with package.json

Note that in CI environments this setting is true by default. If you still need to run install in such cases, use "pnpm install --no-frozen-lockfile"
  • As instructed in the 2nd line, use the command pnpm install --no-frozen-lockfile for deployment.
pnpm install --no-frozen-lockfile
  • So go to the project settings in vercel --> General --> Install Command --> Override --> Paste this command.
  • The error occered on the “vercel build” stage but the error log suggested us an install command 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-lockfile flag turned on. It is turned on by default, you can switch off by doing this:

pnpm install --frozen-lockfile=false

ENABLE_EXPERIMENTAL_COREPACK=1 environment 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=false to .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-lockfile

This error happens when you have .npmrc in your HOME directory with values such as auto-install-peers=true because your Vercel deployment won’t know about those local settings.

To solve this problem, you can commit your .npmrc to 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 ~/.npmrc in your home directory will impact all installs on your machine so its best delete strict-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!

@haneenmahd

The first line says Lockfile is up-to-date, and then it just fails.

And I install successfully locally, so it must be something wrong on Vercel’s building progress.

you might have solved it, but just in case someone else faces it. Rune the command pnpm install --fix-lockfile, and you should notice a changes with your lockfile.

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:

...
13:35:42.431 | Running "vercel build"
13:35:42.945 | Vercel CLI 27.3.8
13:35:43.269 | Detected ENABLE_EXPERIMENTAL_COREPACK=1 and "pnpm@7.9.0" in package.json
13:35:43.565 | Installing dependencies...
13:35:44.905 | Lockfile is up to date, resolution step is skipped
13:35:44.909 | ERR_PNPM_OUTDATED_LOCKFILE  Cannot install with "frozen-lockfile" because pnpm-lock.yaml is not up to date with package.json
13:35:44.909 |  
13:35:44.909 | Note that in CI environments this setting is true by default. If you still need to run install in such cases, use "pnpm install --no-frozen-lockfile"
13:35:44.931 | Error! Command "pnpm install" exited with 1

On my local, both pnpm i and pnpm i --frozen-lockfile runs without issue. I’ve run pnpm up before so pnpm-lock.yaml not being up to date is false.

I run pnpm just successfully, maybe the pnpm version is not always latest on Vercel’s environment.