vercel: Regression: `vercel build` fails with pnpm v9.1.x on latest Vercel CLI

https://github.com/vercel/vercel/pull/11596 seems to have introduced a regression in https://github.com/vercel/vercel/releases/tag/vercel%4034.2.0 when building with pnpm v9.1.0

Preview build logs before (notice CLI v.34.1.10)

[14:55:14.413] Running build in Washington, D.C., USA (East) – iad1
[14:55:14.541] Cloning [redacted]
[14:55:15.238] Cloning completed: 696.768ms
[14:55:15.239] Running "[ $(git branch --show-current) == "main" ]"
[14:55:15.652] Found .vercelignore
[14:55:15.665] Removed 4 ignored files defined in .vercelignore
[14:55:27.118] Restored build cache
[14:55:27.242] Running "vercel build"
[14:55:28.196] Vercel CLI 34.1.10
[14:55:29.754] Detected `pnpm-lock.yaml` version 9 generated by pnpm 8
[14:55:29.803] Installing dependencies...

Preview build logs after (notice CLI v34.2.0)

[16:08:05.141] Running build in Washington, D.C., USA (East) – iad1
[16:08:05.270] Cloning [redacted]
[16:08:06.157] Cloning completed: 886.836ms
[16:08:06.157] Running "[ $(git branch --show-current) == "main" ]"
[16:08:06.707] Found .vercelignore
[16:08:06.718] Removed 4 ignored files defined in .vercelignore
[16:08:38.984] Restored build cache
[16:08:39.073] Running "vercel build"
[16:08:40.095] Vercel CLI 34.2.0
[16:08:40.668] Detected `pnpm-lock.yaml` version 9 generated by pnpm 9
[16:08:40.701] Installing dependencies...
[16:08:41.533]  ERR_PNPM_BAD_PM_VERSION  This project is configured to use v9.1.0 of pnpm. Your current pnpm is v9.0.4
[16:08:41.533] 
[16:08:41.534] If you want to bypass this version check, you can set the "package-manager-strict" configuration to "false" or set the "COREPACK_ENABLE_STRICT" environment variable to "0"
[16:08:41.550] Error: Command "pnpm install" exited with 1
[16:08:42.394] 

package.json has

  "packageManager": "pnpm@9.1.0",

and pnpm-lock.json has

lockfileVersion: '9.0'

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 29
  • Comments: 26 (6 by maintainers)

Commits related to this issue

Most upvoted comments

There are two different errors here, but they look very similar. Please take note of the exact error message for mitigation options below.

Note that Vercel uses specific versions of major versions of pnpm by default. These can change, but right now, we support these versions of pnpm:

  • pnpm@6.35.1
  • pnpm@7.33.5
  • pnpm@8.15.8
  • pnpm@9.0.4

The proper matching major version is used based on the lockfile version and the package.json#packageManager version (if it exists).

If you want the exact version specified in package.json#packageManager, you need to enable corepack on Vercel.

We’re working on improving this developer experience in general, as well.

pnpm error ERR_PNPM_UNSUPPORTED_ENGINE

For anyone seeing the ERR_PNPM_UNSUPPORTED_ENGINE error from pnpm, you can work around this problem by doing any of the following:

  • enable corepack (vercel docs)
    • set env var ENABLE_EXPERIMENTAL_COREPACK to 1
    • make sure you have a matching package.json#packageManager value
  • remove your package.json#engines.pnpm value (pnpm docs)

cc @Jarrku

pnpm error ERR_PNPM_BAD_PM_VERSION

For anyone seeing the ERR_PNPM_BAD_PM_VERSION error from pnpm, you can work around this problem by doing any of the following:

  • enable corepack (vercel docs)
    • set env var ENABLE_EXPERIMENTAL_COREPACK to 1
  • disable corepack strictness (pnpm docs) (corepack docs)
    • set env var COREPACK_ENABLE_STRICT to 0
    • this is necessary even if you aren’t using corepack because pnpm checks this value
  • disable package manager strictness (pnpm docs)
    • set package-manager-strict to false in .npmrc

cc @AurelienGasser

Also running into this issue, our builds started failing somewhere today, as it’s not detecting the pnpm override anymore it seems.

Logs from a build ~8h ago:

--
16:55:52.394 | Restored build cache
16:55:52.481 | Running "vercel build"
16:55:52.944 | Vercel CLI 34.1.10
16:55:53.120 | > Detected Turbo. Adjusting default settings...
16:55:54.739 | > Detected ENABLE_EXPERIMENTAL_COREPACK=1 and "pnpm@9.1.1" in package.json
16:55:55.008 | Running "install" command: `pnpm install`...
16:55:55.703 | Scope: all 18 workspace projects
16:55:59.584 |  
16:55:59.701 | ../../../.. prepare$ husky
16:55:59.784 | ../../../.. prepare: Done
16:56:00.103 | Done in 4.9s

Logs I’m getting now:

Restored build cache
01:09:24.816 | Running "vercel build"
01:09:25.254 | Vercel CLI 34.2.0
01:09:25.403 | > Detected Turbo. Adjusting default settings...
01:09:25.845 | > Detected ENABLE_EXPERIMENTAL_COREPACK=1 and "pnpm@9.1.1" in package.json
01:09:26.107 | Detected `pnpm-lock.yaml` version 9 generated by pnpm 9
01:09:26.107 | Running "install" command: `pnpm install`...
01:09:26.660 | WARN  This project is configured to use v9.1.1 of pnpm. Your current pnpm is v9.0.4
01:09:26.662 | ERR_PNPM_UNSUPPORTED_ENGINE  Unsupported environment (bad pnpm and/or Node.js version)
01:09:26.663 |  
01:09:26.663 | Your pnpm version is incompatible with "/vercel/path0".
01:09:26.663 |  
01:09:26.663 | Expected version: ^9.1.1
01:09:26.663 | Got: 9.0.4
01:09:26.663 |  
01:09:26.663 | This is happening because the package's manifest has an engines.pnpm field specified.
01:09:26.663 | To fix this issue, install the required pnpm version globally.
01:09:26.663 |  
01:09:26.663 | To install the latest version of pnpm, run "pnpm i -g pnpm".
01:09:26.663 | To check your pnpm version, run "pnpm -v".
01:09:26.676 | Error: Command "pnpm install" exited with 1

pnpm error ERR_PNPM_BAD_PM_VERSION

We’ve rolled out a change that disables pnpm@9’s strictness when checking the package.json#packageManager value. You can still enable this strictness in your project by setting package-manager-strict to true in your .npmrc.

You will still see pnpm’s warning when these versions don’t match, but it will not error and break the build on Vercel.

That issue should be resolved for everyone now. If you still encounter it, let me know in this thread.

Corepack enabled, but still getting ERR_PNPM_UNSUPPORTED_ENGINE

We’re still digging into this. I’ve not been able to reproduce it a single time.

If you are still seeing this, let me know!

If you have a reproduction, let me know!

You can respond here and/or send a tarball of a project that reproduces the problem to sean.massa@vercel.com. Thanks!

@Jarrku you should be able to have it working like that. I didn’t notice in your logs that corepack was already enabled. That’s a separate issue.

Corepack enabled, but still getting ERR_PNPM_UNSUPPORTED_ENGINE

If you see both these items in your logs:

  • Detected ENABLE_EXPERIMENTAL_COREPACK=1 ...
  • ERR_PNPM_UNSUPPORTED_ENGINE

Then you have a special case of this error. We’re diagnosing this problem know. If you can share your project, a specific deployment, even source code, that’d be awesome. Feel free to email me a zip even, if that’s possible, at sean.massa@vercel.com.

It started this morning with no changes on our end. If @Jarrku doesn’t get more info for you I can try to look into it on Monday. We ended up pinning our version of pnpm to 9.0.4 to match vercel for now.

cruisecritic-com_–_Deployment_Overview

@Jarrku you should be able to have it working like that. I didn’t notice in your logs that corepack was already enabled. That’s a separate issue.

Corepack enabled, but still getting ERR_PNPM_UNSUPPORTED_ENGINE

If you see both these items in your logs:

  • Detected ENABLE_EXPERIMENTAL_COREPACK=1 ...
  • ERR_PNPM_UNSUPPORTED_ENGINE

Then you have a special case of this error. We’re diagnosing this problem now. If you can share your project, a specific deployment, even source code, that’d be awesome. Feel free to email me a zip even, if that’s possible, at sean.massa@vercel.com.

We rolled out a fix that detects packageManager in the root package.json! It is no longer necessary to define packageManager in every package of a monorepo.

Turborepo projects using corepack may see corepack getting disabled. To solve this, either:

I have the same problem with a monorepo. To solve it I had to set the engines and packageManager in every package because Vercel does not look at the engines and packageManager in the root package.json. Additionally I had to set this environment variable for all builds: ENABLE_EXPERIMENTAL_COREPACK=1 image

Looks like it’s not enough to set ENABLE_EXPERIMENTAL_COREPACK to 1. You need to remove pnpm from engines in package.json which is weird because you want it for errors in version mismatch for local development.

And it doesn’t look like corepack works or how should I interpret this?

> Detected ENABLE_EXPERIMENTAL_COREPACK=1 and "pnpm@9.10.0" in package.json
Detected `pnpm-lock.yaml` version 9 generated by pnpm@9.x
Running "install" command: `pnpm install`...
../.. |  WARN  Unsupported engine: wanted: {"node":"20.12.2"} (current: {"node":"v20.17.0","pnpm":"9.4.0"})

I think I’ve managed to reproduce it… I don’t think it’s reproducible by a codebase alone, but I think it may have something to do with turborepo - it would be great if others can others confirm that they are also using turborepo.

@nerdo, yes we are using turborepo as well. And my feeling was that it had to do with some tool. I was thinking next but turborepo would make sense as well.

Doesn’t seem to be solved yet, tried with the latest PNPM 9.1.3 and the issue persists.

@EndangeredMassa

On my phone currently, but here’s a deployment link https://vercel.com/pexip-engage/booking-plugin/FMxsmUohJXkv8rByEV3ZaE9PrjRY

Most of our projects under pexip engage are failing.

I can share the root package json if that’s helpful?

@EndangeredMassa

We have corepack enabled & have packageManager set to 9.1.1

If I understand correctly, we should not set the engines field, because this overrules the other settings?