0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【React初心者】Herokuデプロイ時のエラー

Posted at
結論:yarn.lockとpackge.lock.jsonのコンフリクトが原因。

以下デプロイできるまでの過程です。

1.creste-react-appでアプリを作成。

2.アプリをHerokuにデプロイ。git push heroku master実行も下記文言と共にエラー。

[rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://git.heroku.com/*****.git'

Gitのmasterとローカルレポジトリにあるブランチの内容に不一致の場合に発生するエラーとのこと。

3.Gitでmargeをしてから再度push。また同一の文言でエラー。
masterブランチでのみの作業だったのでmargeが原因ではなさそう。

4.Herokuのマイページにログインしてログを確認する。

これは結構大切だと思いました。エラーの原因もここでわかりました。

Two different lockfiles found: package-lock.json and yarn.lock
Both npm and yarn have created lockfiles for this application,
but only one can be used to install dependencies. Installing
dependencies using the wrong package manager can result in missing
packages or subtle bugs in production.

5.yarn.lockとpackage.lock.jsonのどちらかを削除する。
私の場合はyarnを消しました。

どちらの方が良いかは他の方の記事を参考にしてみてください。
今回はHerokuでしたが他のサーバでもエラーになるんでしょうね。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?