尝试推送React应用时,Heroku“无法推送一些引用”

时间:2019-10-22 00:54:16

标签: javascript git heroku create-react-app

请按以下步骤操作:https://dev.to/smithmanny/deploy-your-react-app-to-heroku-2b6f,我正在尝试将一个简单的React应用程序从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,每次都得到相同的结果。

1 个答案:

答案 0 :(得分: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