我正在尝试将我的NextJS应用程序部署到Vercel上,但是每次在部署阶段,我都会遇到这些错误,部署将失败:
Previous build cache not available
Cloning completed: 426.52ms
Running "vercel build"
Vercel CLI 28.6.0
Installing dependencies...
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: react-typed@1.2.0
npm ERR! Found: react@18.2.0
npm ERR! node_modules/react
npm ERR! react@"18.2.0" from the root project
npm ERR! peer react@"^18.2.0" from next@13.0.5
npm ERR! node_modules/next
npm ERR! next@"13.0.5" from the root project
npm ERR! 3 more (react-dom, react-icons, styled-jsx)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.3.0" from react-typed@1.2.0
npm ERR! node_modules/react-typed
npm ERR! react-typed@"^1.2.0" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: react@16.14.0
npm ERR! node_modules/react
npm ERR! peer react@"^16.3.0" from react-typed@1.2.0
npm ERR! node_modules/react-typed
npm ERR! react-typed@"^1.2.0" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See /vercel/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /vercel/.npm/_logs/2022-12-02T16_42_09_037Z-debug-0.log
Error: Command "npm install" exited with 1
我尝试过运行npm install --legacy-peer-deps
并尝试将其重新部署到Vercel上,但同样的问题仍然存在。当我使用npm run dev
在localhost:3000上运行这个应用程序时,应用程序会呈现良好的效果。有人知道我能做什么吗?
我试过了
npm install --legacy-peer-deps
并将这些更改推送到我的GitHub存储库。在重新部署时,同样的问题仍然会显示。我跑
npm install --legacy-peer-deps
再说一次,但这一次,没有更多的改变要做。
发布于 2022-12-03 08:57:21
您可以通过以下方法覆盖Vercel CLI使用的安装命令:
将
npm install --legacy-peer-deps
放在项目根目录中的npm install --legacy-peer-deps
中,该文件应包含:// vercel.json
{
"installCommand": "npm install --legacy-peer-deps"
}
在推动和等待部署之后,应该会经历这一次。
但我建议找出这个问题的原因。您使用的某些依赖项似乎依赖于react-typed
,而后者不再被维护。最好是找个替代方案
https://stackoverflow.com/questions/74659077
复制相似问题