首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >部署到Vercel时发生对等依赖错误

部署到Vercel时发生对等依赖错误
EN

Stack Overflow用户
提问于 2022-12-02 16:55:58
回答 1查看 12关注 0票数 0

我正在尝试将我的NextJS应用程序部署到Vercel上,但是每次在部署阶段,我都会遇到这些错误,部署将失败:

代码语言:javascript
运行
复制
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上运行这个应用程序时,应用程序会呈现良好的效果。有人知道我能做什么吗?

我试过了

代码语言:javascript
运行
复制
npm install --legacy-peer-deps

并将这些更改推送到我的GitHub存储库。在重新部署时,同样的问题仍然会显示。我跑

代码语言:javascript
运行
复制
npm install --legacy-peer-deps

再说一次,但这一次,没有更多的改变要做。

EN

回答 1

Stack Overflow用户

发布于 2022-12-03 08:57:21

您可以通过以下方法覆盖Vercel CLI使用的安装命令:

  1. 转到Vercel仪表板-> -> Settings -> General -> Scroll到Build & Development Settings,并将npm install --legacy-peer-deps放在项目根目录中的npm install --legacy-peer-deps中,该文件应包含:

代码语言:javascript
运行
复制
// vercel.json
{
  "installCommand": "npm install --legacy-peer-deps"
}

在推动和等待部署之后,应该会经历这一次。

但我建议找出这个问题的原因。您使用的某些依赖项似乎依赖于react-typed,而后者不再被维护。最好是找个替代方案

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74659077

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档