在 Heroku 上更新我的 ReactJS 网站失败

Updating my ReactJS website on Heroku failed

我想更改我在 heroku 上托管的 React.JS 网站,我按照以下步骤编辑我的网站:

运行 git add . 运行 git commit -m "make it better" 最后 运行 git push origin main

报错后,我运行npm cache clean --force&npm i --force无果

然后我不断收到以下错误:

remote: Building source:
remote: 
remote: -----> Building on the Heroku-20 stack
remote: -----> Using buildpack: heroku/nodejs
remote: -----> Node.js app detected
remote:        
remote: -----> Creating runtime environment
remote:
remote:        NPM_CONFIG_LOGLEVEL=error
remote:        NODE_VERBOSE=false
remote:        NODE_ENV=production
remote:        NODE_MODULES_CACHE=true
remote:
remote: -----> Installing binaries
remote:        engines.node (package.json):  unspecified
remote:        engines.npm (package.json):   unspecified (use default)
remote:
remote:        Resolving node version 16.x...
remote:        Downloading and installing node 16.14.2...
remote:        Using default npm version: 8.5.0
remote:        
remote: -----> Restoring cache
remote:        Cached directories were not restored due to a change in version of node, npm, yarn or stack
remote:        Module installation may take longer for this build
remote:        
remote: -----> Installing dependencies
remote:        Installing node modules (package.json)
remote:        npm ERR! code ERESOLVE
remote:        npm ERR! ERESOLVE unable to resolve dependency tree
remote:        npm ERR!
remote:        npm ERR! While resolving: my-portfolio-website@0.1.0
remote:        npm ERR! Found: @emotion/styled@11.8.1
remote:        npm ERR! node_modules/@emotion/styled
remote:        npm ERR!   @emotion/styled@"^11.8.1" from the root project
remote:        npm ERR!
remote:        npm ERR! Could not resolve dependency:
remote:        npm ERR! peer @emotion/styled@"^10.0.27" from @material-ui/styled-engine@5.0.0-alpha.11
remote:        npm ERR! node_modules/@material-ui/styled-engine
remote:        npm ERR!   @material-ui/styled-engine@"^5.0.0-alpha.11" 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.rdttK/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.rdttK/_logs/2022-03-21T08_48_10_190Z-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:        - Node version not specified in package.json
remote:          https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version

编辑后,我想将更改推送到主分支。

我猜您在构建应用程序时使用的是旧版本的 node.js,如果是这样,请尝试在 package.json 文件中添加以下行:

"engines":
 {
    "node": "14.16.1", 
     "npm": "6.14.12"
 }