Heroku由于依赖性问题而没有部署构建

发布于 2025-02-04 07:19:58 字数 4986 浏览 1 评论 0原文

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

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: [email protected]
    remote:        npm ERR! Found: [email protected]
    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/[email protected]
    remote:        npm ERR!   node_modules/@apollo/react-common
    remote:        npm ERR!     @apollo/react-common@"^3.1.4" from @apollo/[email protected]
    remote:        npm ERR!     node_modules/@apollo/react-components
    remote:        npm ERR!       @apollo/react-components@"^3.1.5" from @apollo/[email protected]
    remote:        npm ERR!       node_modules/@apollo/react-hoc
    remote:        npm ERR!         @apollo/react-hoc@"^3.1.5" from [email protected]
    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/[email protected]
    remote:        npm ERR!     node_modules/@apollo/react-hoc
    remote:        npm ERR!       @apollo/react-hoc@"^3.1.5" from [email protected]
    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 [email protected]
    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 [email protected]
    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: [email protected]
    remote:        npm ERR! node_modules/react
    remote:        npm ERR!   peer react@"^17.0.2 || ^18.0.0-0" from [email protected]
    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 [email protected]
    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

while deploying build in heroku ,its causing an dependency error ,does anyone have faced the same ? What would be the root cause ? Any idea to resolve this ?
The heroku build used to work before but now this error happens and its confusing really

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: [email protected]
    remote:        npm ERR! Found: [email protected]
    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/[email protected]
    remote:        npm ERR!   node_modules/@apollo/react-common
    remote:        npm ERR!     @apollo/react-common@"^3.1.4" from @apollo/[email protected]
    remote:        npm ERR!     node_modules/@apollo/react-components
    remote:        npm ERR!       @apollo/react-components@"^3.1.5" from @apollo/[email protected]
    remote:        npm ERR!       node_modules/@apollo/react-hoc
    remote:        npm ERR!         @apollo/react-hoc@"^3.1.5" from [email protected]
    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/[email protected]
    remote:        npm ERR!     node_modules/@apollo/react-hoc
    remote:        npm ERR!       @apollo/react-hoc@"^3.1.5" from [email protected]
    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 [email protected]
    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 [email protected]
    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: [email protected]
    remote:        npm ERR! node_modules/react
    remote:        npm ERR!   peer react@"^17.0.2 || ^18.0.0-0" from [email protected]
    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 [email protected]
    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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

沫尐诺 2025-02-11 07:19:58

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

add NPM_CONFIG_LEGACY_PEER_DEPS environmental variable to your Heroku app and set its value to true.
enter image description here

浮世清欢 2025-02-11 07:19:58

几天前(6月初)也遇到了同样的问题,同时在Heroku上部署了我的React应用程序。似乎问题是由NPM版本更新引起的。默认情况下,Heroku使用最新的稳定版本的节点和NPM作为建筑引擎,但是如果您使用以前的版本,则可能会导致依赖性相互矛盾。

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

使用node -versionnpm-version要查看本地实例上的版本,然后在您的package.json文件中的引擎段下添加它们(如您拥有的版本,替换16.0.0和7.10.0):

"engines": {
    "node": "16.0.0",
    "npm": "7.10.0"
},

然后重新启动应用程序。在Heroku上。问题应解决。

I had the same issue a few days ago (early June) while deploying my React app on Heroku as well. It seems the problem was caused by the npm version update. By default, Heroku uses the latest stable version of node and npm as the building engines, but it might lead to conflicting dependencies if you use a previous version of them.

So, if it works completely fine locally but this issue happens while deploying it on Heroku, here is the solution:

Use node --version and npm --version to check out the versions on your local instance, and then add them under engines section in your package.json file, like this (replace 16.0.0 and 7.10.0 with the versions you have):

"engines": {
    "node": "16.0.0",
    "npm": "7.10.0"
},

then redeploy the app on Heroku. Problem should be fixed.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文