【发布时间】: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:master 和git push heroku HEAD:master,每次都得到相同的结果。
【问题讨论】:
-
确保您只使用 yarn 或 npm。如果你不想使用 yarn 删除 yarn.lock 文件。 npm 的想法相同。
-
我几乎发现我必须在没有 yarn.lock 的情况下重新开始。如果那里有一个,而您稍后将其删除,那么它仍然会失败。
标签: javascript git heroku create-react-app