我正在构建一个 crud 应用程序,其中在前端我使用了 react,在后端我使用了 nodejs 和 express。当我尝试将 app.js 推送到 heroku 时,出现此错误。 我已经尝试了很多我在互联网上找到的方法。但我仍然遇到同样的错误。
git push heroku master
Enumerating objects: 1235, done.
Counting objects: 100% (1235/1235), done.
Delta compression using up to 4 threads
Compressing objects: 100% (1187/1187), done.
Writing objects: 100% (1235/1235), 2.19 MiB | 949.00 KiB/s, done.
Total 1235 (delta 120), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Building on the Heroku-20 stack
remote: -----> Determining which buildpack to use for this app
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: !
remote: ! ## Warning - The same version of this code has already been built: 6f7f0c809a340fce866cad56f94827ead03983b4
remote: !
remote: ! We have detected that you have triggered a build from source code with version 6f7f0c809a340fce866cad56f94827ead03983b4
remote: ! at least twice. One common cause of this behavior is attempting to deploy code from a different branch.
remote: !
remote: ! If you are developing on a branch and deploying via git you must run:
remote: !
remote: ! git push heroku <branchname>:main
remote: !
remote: ! This article goes into details on the behavior:
remote: ! https://devcenter.heroku.com/articles/duplicate-build-version
remote:
remote: Verifying deploy...
remote:
remote: ! Push rejected to mern-crud-in.
remote:
To https://git.heroku.com/mern-crud-in.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/mern-crud-in.git'