按此进行: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 页面,但到目前为止还没有看到解决方案。我不应该说我在那里有一些应用程序和 Remote ,但我想我已经删除了所有应用程序和 Remote ,并试图从头开始......除非还有其他东西需要清理......
我试过这个:Push to Heroku denied - "failed to push some refs to 'heroku" .所以我尝试了:git push heroku master:master
和 git push heroku HEAD:master
每次都得到相同的结果。
最佳答案
If there was one in there, and you remove it later, then it still fails.
它不应该,如果你删除它并且提交,记录删除:
如 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
关于javascript - 尝试推送 React 应用程序时出现 Heroku "failed to push some refs",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58495821/