I host my Nuxt project on Vercel. Everything was fine until now.

From now, all builds are throwing this error:

[19:25:54.681] Running "vercel build"
[19:25:55.722] Vercel CLI 33.6.1
[19:25:57.207] Installing dependencies...
[19:25:57.856] error This project's package.json defines "packageManager": "[email protected]". However the current global version of Yarn is 1.22.22.
[19:25:57.856] 
[19:25:57.856] Presence of the "packageManager" field indicates that the project is meant to be used with Corepack, a tool included by default with all official Node.js distributions starting from 16.9 and 14.19.
[19:25:57.856] Corepack must currently be enabled by running corepack enable in your terminal. For more information, check out https://yarnpkg.com/corepack.
[19:25:57.888] Error: Command "yarn install" exited with 1

Local build is fine, but the thing is that have touched any configuration or package.json from the latest successful build.

How can I enable corepack on Vercel? Or what can cause the problem?

3

There are 3 best solutions below

1
jetxs On BEST ANSWER

When you're using Yarn > v1, you need to enable Corepack, and on Vercel Corepack needs to be enabled with the ENABLE_EXPERIMENTAL_COREPACK environment variable.

Add the ENABLE_EXPERIMENTAL_COREPACK variable with value 1 at the Settings > Environment Variables page in your project

Then deploy a new build.

Usually you need to run corepack enable && yarn install when building, but on Vercel that doesn't work. You'll need to use above environment variable.

0
Boris Grigorov On

It was probably cause by Yarn 2, which is not supported by Vercel. Removing the package manager speification from package.json resolved the problem. However I don't know, how can it not fail till now.

0
loevray On

Delete the package.json internal packageManager property and commit it.

Note: This is not the right way to do it, vercel does not originally support yarn v4 Downgrade to yarn v1 or move to a deployment other than vercel

https://vercel.com/docs/deployments/builds/package-managers

Also, you can set corepack to work, but yarn v4 is not supported by vercel. It's not a corepack issue.

https://vercel.com/docs/deployments/configure-a-build#corepack