LoginSignup
senba1007
@senba1007 (Toshiki Senba)

Are you sure you want to delete the question?

Leaving a resolved question undeleted may help others!

RailsチュートリアルでHerokuのデプロイに失敗しました。

初投稿です。よろしくお願いいたします。

タイトルにもある通り、Railsチュートリアルherokuにデプロイしてみようの章で
git push herokuを実行したところ

$git push heroku

(略)

remote: Compiling…
remote: Compilation failed:
remote: error An unexpected error occurred: "Command \"webpack\" not found.".
remote:
remote: yarn run v1.5.1
remote: info If you think this is a bug, please open a bug report with the information provided in "/tmp/build_ad3a2bb3/yarn-error.log".
remote: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
remote:
remote:
remote: !
remote: ! Precompiling assets failed.
remote: !
remote: ! Push rejected, failed to compile Ruby app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to rails-tutorial-gu-tara.
remote:
To https://git.heroku.com/rails-tutorial-gu-tara.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/rails-tutorial-gu-tara.git'

と表示されプッシュできませんでした。

その後エラー文を見ていたら

①remote: error @rails/webpacker@4.3.0: The engine "node" is incompatible with this module. Expected version ">=8.16.0".
remote: error An unexpected error occurred: "Found incompatible module".
remote: info If you think this is a bug, please open a bug report with the information provided in "/tmp/build_ad3a2bb3/yarn-error.log".

➁remote: Compilation failed:
remote: error An unexpected error occurred: "Command \"webpack\" not found.".

の二つが見つかりました。

試した事
1 $ yarn install
これは問題なくできたが結果同じエラー文が出てきました。

2 $ yarn upgrade のち git commitとpushを行う
参考記事https://qiita.com/oieioi/items/78da19ccd40811e8f528
これも正常に作動し再度同じエラー文が出てきました。

webpack周辺の知識がないのでお力をお借りしたいです。よろしくお願いいたします。

2

1Answer

The engine "node" is incompatible with this module. Expected version ">=8.16.0".

Heroku 側の Node.js のバージョンが8.16.0未満のせいで @rails/webpacker@4.3.0 モジュールのインストールに失敗しているようです。 yarn のバージョンも1.5.1と古いです。 Heroku の Node.js のデフォルトバージョンについて検索してみました。

If you are deploying a Ruby application with the webpacker gem you will now get yarn version 1.5.1 installed . Node is now 8.9.4.

ということなので、この記事の状況から変わっていないなら、 Rails アプリをデプロイしたときは Node.js 8.9.4, yarn 1.5.1 が用意されるのでしょう。

Heroku 側の Node.js や Ruby は buildpacks という仕組みで管理されています。より新しいバージョンの Node.js をインストールするには、以下のコマンドで heroku/nodejs buildpack を追加します。

heroku buildpacks:add --index 1 heroku/nodejs

今なら Node.js 12.x がインストールされます。この後に適当なコミットを追加してもう一度 git push すればデプロイできるはずです。

6

Comments

  1. @senba1007

    Questioner
    うまくいきました!ありがとうございます!

Your answer might help someone💌