【问题标题】:Heroku Deploy: Facing build error after updating NextJSHeroku Deploy:更新 NextJS 后面临构建错误
【发布时间】:2023-01-12 18:12:06
【问题描述】:

我已经更新了 NextJS,在更新它并在 Heroku 上推送更改后,我遇到了构建错误,在本地一切正常,我什至可以在不使用 -force 或 --legacy-peer-deps 命令的情况下安装所有 NPM。但是在部署时仍然遇到包问题。

-----> 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。但仍然无法解决服务器上的这个问题

【问题讨论】:

    标签: node.js heroku next.js deployment build-error


    【解决方案1】:

    请尝试在您的 package.json 文件中定义引擎

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

    【讨论】:

      【解决方案2】:

      Heroku 服务器期望服务器上存在的 package-lock.json 文件与将要部署的文件相同。 所以,我删除了服务器上的文件并再次推送它(本地可用的)并且一切正常。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-12-24
        • 2022-06-21
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-06-12
        • 2020-07-24
        • 2017-01-13
        相关资源
        最近更新 更多