首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >由于依赖关系问题,Heroku没有部署构建

由于依赖关系问题,Heroku没有部署构建
EN

Stack Overflow用户
提问于 2022-06-03 13:08:13
回答 2查看 775关注 0票数 4

在heroku中部署构建时,它会导致依赖错误,是否有人面临过同样的问题?根本原因是什么?有办法解决这个问题吗?heroku构建以前曾经工作过,但是现在这个错误发生了,它真的让人困惑。

代码语言:javascript
复制
remote: -----> Installing dependencies
    remote:        Installing node modules
    remote:        npm ERR! code ERESOLVE
    remote:        npm ERR! ERESOLVE could not resolve
    remote:        npm ERR! 
    remote:        npm ERR! While resolving: next@12.1.6
    remote:        npm ERR! Found: react@16.14.0
    remote:        npm ERR! node_modules/react
    remote:        npm ERR!   react@"^16.10.1" from the root project
    remote:        npm ERR!   peer react@"^16.8.0" from @apollo/react-common@3.1.4
    remote:        npm ERR!   node_modules/@apollo/react-common
    remote:        npm ERR!     @apollo/react-common@"^3.1.4" from @apollo/react-components@3.1.5
    remote:        npm ERR!     node_modules/@apollo/react-components
    remote:        npm ERR!       @apollo/react-components@"^3.1.5" from @apollo/react-hoc@3.1.5
    remote:        npm ERR!       node_modules/@apollo/react-hoc
    remote:        npm ERR!         @apollo/react-hoc@"^3.1.5" from react-apollo@3.1.5
    remote:        npm ERR!         node_modules/react-apollo
    remote:        npm ERR!       1 more (react-apollo)
    remote:        npm ERR!     @apollo/react-common@"^3.1.4" from @apollo/react-hoc@3.1.5
    remote:        npm ERR!     node_modules/@apollo/react-hoc
    remote:        npm ERR!       @apollo/react-hoc@"^3.1.5" from react-apollo@3.1.5
    remote:        npm ERR!       node_modules/react-apollo
    remote:        npm ERR!         react-apollo@"^3.1.3" from the root project
    remote:        npm ERR!     3 more (@apollo/react-hooks, @apollo/react-ssr, react-apollo)
    remote:        npm ERR!   14 more (@apollo/react-components, @apollo/react-hoc, ...)
    remote:        npm ERR! 
    remote:        npm ERR! Could not resolve dependency:
    remote:        npm ERR! peer react@"^17.0.2 || ^18.0.0-0" from next@12.1.6
    remote:        npm ERR! node_modules/next
    remote:        npm ERR!   next@"^12.1.6" from the root project
    remote:        npm ERR!   peer next@">= 5.1.0" from next-env@1.1.1
    remote:        npm ERR!   node_modules/next-env
    remote:        npm ERR!     next-env@"^1.1.0" from the root project
    remote:        npm ERR! 
    remote:        npm ERR! Conflicting peer dependency: react@18.1.0
    remote:        npm ERR! node_modules/react
    remote:        npm ERR!   peer react@"^17.0.2 || ^18.0.0-0" from next@12.1.6
    remote:        npm ERR!   node_modules/next
    remote:        npm ERR!     next@"^12.1.6" from the root project
    remote:        npm ERR!     peer next@">= 5.1.0" from next-env@1.1.1
    remote:        npm ERR!     node_modules/next-env
    remote:        npm ERR!       next-env@"^1.1.0" from the root project
    remote:        npm ERR! 
    remote:        npm ERR! Fix the upstream dependency conflict, or retry
    remote:        npm ERR! this command with --force, or --legacy-peer-deps
    remote:        npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
    remote:        npm ERR! 
    remote:        npm ERR! See /tmp/npmcache.KnKS4/eresolve-report.txt for a full report.
    remote:        
    remote:        npm ERR! A complete log of this run can be found in:
    remote:        npm ERR!     /tmp/npmcache.KnKS4/_logs/2022-06-03T12_47_36_545Z-debug-0.log
    remote: 
    remote: -----> Build failed
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2022-06-10 20:00:22

几天前(6月初),我在Heroku上部署了我的React应用程序,我也遇到了同样的问题。问题似乎是由国家预防机制版本更新引起的。默认情况下,Heroku使用节点和npm的最新稳定版本作为构建引擎,但如果使用以前的版本,则可能会导致相互冲突的依赖关系。

因此,如果在本地完全正常,但是在Heroku上部署它时会发生此问题,下面是解决方案:

使用node --versionnpm --version签出本地实例上的版本,然后将它们添加到package.json文件中的engines部分中,如下所示(用所拥有的版本替换16.0.0和7.10.0 ):

代码语言:javascript
复制
"engines": {
    "node": "16.0.0",
    "npm": "7.10.0"
},

然后将应用程序重新部署到Heroku上。问题应该解决。

票数 3
EN

Stack Overflow用户

发布于 2022-06-23 00:01:24

NPM_CONFIG_LEGACY_PEER_DEPS环境变量添加到Heroku应用程序中,并将其值设置为true

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

https://stackoverflow.com/questions/72490093

复制
相关文章

相似问题

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