Heroku Deploy:更新NextJS后面临构建错误



我已经更新了NextJS,在更新它并在Heroku上推送更改后,我遇到了一个构建错误,在本地一切都很好,我甚至可以安装所有的npm而不使用-force或-legacy-peer-deps命令。但在部署时仍然遇到包问题。

-----> Building on the Heroku-22 stack
-----> Using buildpack: heroku/nodejs
-----> Node.js app detected

-----> Creating runtime environment

NPM_CONFIG_LOGLEVEL=error
NODE_VERBOSE=false
NODE_ENV=production
NODE_MODULES_CACHE=true

-----> Installing binaries
engines.node (package.json):  16.15.0
engines.npm (package.json):   8.5.5

Resolving node version 16.15.0...
Downloading and installing node 16.15.0...
npm 8.5.5 already installed with node

-----> Restoring cache
- npm cache

-----> Installing dependencies
Installing node modules
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR! 
npm ERR! While resolving: isxy-prototype-next-scratch@undefined
npm ERR! Found: next@12.0.7
npm ERR! node_modules/next
npm ERR!   next@"13.1.1" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! next@"13.1.1" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: react@18.2.0
npm ERR! node_modules/react
npm ERR!   peer react@"^18.2.0" from next@13.1.1
npm ERR!   node_modules/next
npm ERR!     next@"13.1.1" 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 /tmp/npmcache.IAUlC/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /tmp/npmcache.IAUlC/_logs/2023-01-11T06_56_44_322Z-debug-0.log
-----> Build failed

我已经尝试删除所有的节点模块,清理缓存,然后我尝试重新安装npms。但是仍然没有办法在服务器

上解决这个问题。

请尝试在您的包中定义引擎。json文件

"engines": {
"node": "16.x",
"npm": "8.5.5"
},

Heroku服务器需要包锁。服务器上的Json文件必须与将要部署的文件相同。所以,我删除了服务器上的文件,并再次推送它(本地可用的),一切都很好。

相关内容

  • 没有找到相关文章

最新更新