2
5

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 5 years have passed since last update.

NuxtのプロジェクトをHerokuにデプロイするときに出たエラーの対処(備忘録)

Last updated at Posted at 2018-12-19

Nuxtで作成したプロジェクトをいざHerokuにデプロイしようとしたときに以下のエラーが出ました。

To https://git.heroku.com/xxxxx-xxxxx.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/xxxxx-xxxxx.git'

Herokuは数ヶ月前に使っていたことがあり、前回と同じような手順でデプロイしてみましたが、ダメでした。このエラーの内容を辿っていくと

-----> Building dependencies
       Installing node modules (yarn.lock)
       yarn install v1.13.0
       [1/4] Resolving packages...
       error Your lockfile needs to be updated, but yarn was run with `--frozen-lockfile`.
       info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
-----> Build failed
 !     Outdated Yarn lockfile
       Your application contains a Yarn lockfile (yarn.lock) which does not
       match the dependencies in package.json. This can happen if you use npm
       to install or update a dependency instead of Yarn.
       Please run the following command in your application directory and check
       in the new yarn.lock file:
       $ yarn install
       $ git add yarn.lock
       $ git commit -m "Updated Yarn lockfile"
       $ git push heroku master
    
       https://kb.heroku.com/why-is-my-node-js-build-failing-because-of-an-outdated-yarn-lockfile
 !     Push rejected, failed to compile Node.js app.
 !     Push failed

このあたりでBuildが失敗しているようです。
今回のNuxtのプロジェクトではyarnは使っていなかった(と思う)ですが、どうやらこのyarn.lockファイルのバージョンが異なっているためBuildで失敗しているようです。この現象はyarnの代わりにnpmを使っていると起こりうるようです。そこで、プロジェクトでyarnを更新し、yarn.lockをコミットしてから再度Herokuへデプロイしたところ、無事にデプロイできました。

更新
yarn
commit
git add yarn.lock
git commit -m"Update yarn.lock"
git push heroku master
heroku
remote: Verifying deploy... done.
To https://git.heroku.com/xxxxx-xxxxx.git
 * [new branch]      master -> master
2
5
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
2
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?