我正在构建一个React on Rails应用程序。我试图部署到Heroku,并得到以下错误:
remote: npm ERR! code ERESOLVE
remote: npm ERR! ERESOLVE could not resolve
remote: npm ERR!
remote: npm ERR! While resolving: react-beautiful-dnd@13.1.0
remote: npm ERR! Found: react@18.2.0
remote: npm ERR! node_modules/react
remote: npm ERR! react@"^18.2.0" from the root project
remote: npm ERR! peer react@"^18.0.0" from @testing-library/react@13.3.0
remote: npm ERR! node_modules/@testing-library/react
remote: npm ERR! @testing-library/react@"^13.3.0" from the root project
remote: npm ERR! 6 more (react-dom, react-redux, react-router, react-router-dom, ...)
remote: npm ERR!
remote: npm ERR! Could not resolve dependency:
remote: npm ERR! peer react@"^16.8.5 || ^17.0.0" from react-beautiful-dnd@13.1.0
remote: npm ERR! node_modules/react-beautiful-dnd
remote: npm ERR! react-beautiful-dnd@"^13.1.0" from the root project
remote: npm ERR!
remote: npm ERR! Conflicting peer dependency: react@17.0.2
remote: npm ERR! node_modules/react
remote: npm ERR! peer react@"^16.8.5 || ^17.0.0" from react-beautiful-dnd@13.1.0
remote: npm ERR! node_modules/react-beautiful-dnd
remote: npm ERR! react-beautiful-dnd@"^13.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.r4FtS/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.r4FtS/_logs/2022-07-11T20_48_04_946Z-debug-0.log
remote:
remote: -----> Build failed
remote:
remote: We're sorry this build is failing! You can troubleshoot common issues here:
remote: https://devcenter.heroku.com/articles/troubleshooting-node-deploys
remote:
remote: Some possible problems:
remote:
remote: - Dangerous semver range (>) in engines.node
remote: https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version
remote:
remote: Love,
remote: Heroku
remote:
remote: ! Push rejected, failed to compile Node.js app.
remote:
remote: ! Push failed
remote: !
remote: ! ## Warning - The same version of this code has already been built: 883925893eb2737985f5bbd30770d374d9f94ee3
remote: !
remote: ! We have detected that you have triggered a build from source code with version 883925893eb2737985f5bbd30770d374d9f94ee3
remote: ! at least twice. One common cause of this behavior is attempting to deploy code from a different branch.
remote: !
remote: ! If you are developing on a branch and deploying via git you must run:
remote: !
remote: ! git push heroku <branchname>:main
remote: !
remote: ! This article goes into details on the behavior:
remote: ! https://devcenter.heroku.com/articles/duplicate-build-version
remote:
remote: Verifying deploy...
remote:
remote: ! Push rejected to phase-5-capstone.
remote:
To https://git.heroku.com/phase-5-capstone.git
! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/phase-5-capstone.git'
我试着运行git push heroku主要力量和没有解决的问题。我看到react和react-beautiful- end的依赖关系存在问题,但我不确定如何在不破坏它的情况下解决这个问题。有人有什么想法吗?谢谢你!
这是由于React -beautiful-dnd版本13.1.0和React版本18.2.0的兼容性问题。降级到react 17,它就可以工作了,除非你正在使用react悬念,服务器组件或任何其他react 18的功能。
package.json
"react": "^17.0.2",
"react-dom": "^17.0.2",
如果你不能降级,等待React -beautiful- end库与React 18的兼容性。看看github仓库问题,其他人也有同样的问题,也许很快就会修复。https://github.com/atlassian/react-beautiful-dnd/issues/2426