我在 Vercel 上托管我的 Nuxt 项目。到目前为止一切都很好。
从现在开始,所有构建都会抛出此错误:
[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
本地构建没问题,但问题是触及了最新成功构建中的任何配置或 package.json。
如何在 Vercel 上启用 corepack?或者是什么原因导致这个问题?
这可能是由 Vercel 不支持的 Yarn 2 引起的。从 package.json 中删除包管理器规范解决了该问题。但我不知道,怎么到现在才不会失败。
删除 package.json 内部 packageManager 属性并提交。
注意:这不是正确的方法,vercel 最初并不支持yarn v4 降级到yarn v1或移动到vercel以外的部署