【问题标题】:Heroku "failed to push some refs" when trying to push React appHeroku 在尝试推送 React 应用程序时“未能推送一些 refs”
【发布时间】:2020-02-18 02:31:35
【问题描述】:

通过这个:https://dev.to/smithmanny/deploy-your-react-app-to-heroku-2b6f,我正在尝试从 create-react-app 到 Heroku 部署一个开箱即用的简单反应应用程序。

npx create-react-app my-app
cd my-app
npm install

然后将这些添加到 package.json:

"engines": {
    "npm": "6.12.0",
    "node": "10.16.3"
},

然后:

heroku login blah...
git init
git add .
git commit -m "initial commit"
heroku create
git remote add heroku https://git.heroku.com/damp-spire-48480.git (auto-generated name of app)
git push heroku master

然后我明白了:

Enumerating objects: 27666, done.
Counting objects: 100% (27666/27666), done.
Delta compression using up to 8 threads
Compressing objects: 100% (20069/20069), done.
Writing objects: 100% (27666/27666), 24.31 MiB | 362.00 KiB/s, done.
Total 27666 (delta 5987), reused 27666 (delta 5987)
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Node.js app detected
remote: 
remote: -----> Build failed
remote:  !     Two different lockfiles found: package-lock.json and yarn.lock
remote: 
remote:        Both npm and yarn have created lockfiles for this application,
remote:        but only one can be used to install dependencies. Installing
remote:        dependencies using the wrong package manager can result in missing
remote:        packages or subtle bugs in production.
remote: 
remote:        - To use npm to install your application's dependencies please delete
remote:          the yarn.lock file.
remote: 
remote:          $ git rm yarn.lock
remote: 
remote:        - To use yarn to install your application's dependences please delete
remote:          the package-lock.json file.
remote: 
remote:          $ git rm package-lock.json
remote:     
remote:        https://help.heroku.com/0KU2EM53
remote: 
remote:  !     Push rejected, failed to compile Node.js app.
remote: 
remote:  !     Push failed
remote: Verifying deploy...
remote: 
remote: !   Push rejected to damp-spire-48480.
remote: 
To https://git.heroku.com/damp-spire-48480.git
 ! [remote rejected]   master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/damp-spire-48480.git'

我现在查看了一些 SO 页面,但到目前为止还没有找到解决方案。我不应该说我在那里有几个应用程序和遥控器,但我认为我已经删除了所有应用程序和遥控器,并尝试从头开始......除非还有其他东西需要清理......

我试过这个:Push to Heroku denied - "failed to push some refs to 'heroku"。所以我尝试了:git push heroku master:mastergit push heroku HEAD:master,每次都得到相同的结果。

【问题讨论】:

  • 确保您只使用 yarn 或 npm。如果你不想使用 yarn 删除 yarn.lock 文件。 npm 的想法相同。
  • 我几乎发现我必须在没有 yarn.lock 的情况下重新开始。如果那里有一个,而您稍后将其删除,那么它仍然会失败。

标签: javascript git heroku create-react-app


【解决方案1】:

如果其中有一个,而您稍后将其删除,那么它仍然会失败。

它不应该,如果你删除它提交,记录删除:

如 Heroku 页面“Why is my Node.js build failing because of conflicting lock files?”中所述

git rm yarn.lock
git commit -m "Remove yarn lock file"
git push heroku master

和/或

git rm package-lock.json
git commit -m "Remove npm lock file"
git push heroku master

【讨论】:

  • 我同意它会持续存在绝对没有意义。我不认为我可以重现我的步骤来尝试再次看到它。无论如何,我确实从一个全新的 create-react-app 应用程序开始。我可以看到很多可能导致我的问题的差异,当然还有更多。无论如何,在稍后添加我的大部分网站之前,我确实通过该教程的步骤让我的应用程序正常工作。
猜你喜欢
  • 1970-01-01
  • 2019-06-24
  • 2021-03-07
  • 2021-10-14
  • 2014-06-26
  • 2021-03-26
  • 2019-07-16
  • 1970-01-01
相关资源
最近更新 更多