Deploy a Rails App with Webpacker on Heroku

You may have this kind of error when you deploy your rails app with webpacker on heroku:

Using /app/config/webpacker.yml file for setting up webpack paths
[Webpacker] Compiling assets 🎉

[Webpacker] Compilation Failed
yarn run v0.22.0
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

error Command "webpack" not found.

To fix it, you have to add nodejs buildpack before ruby buildback in heroku settings. heroku buildpack

Or in your app.json, your buidpack section should be like:

    {
      "url": "heroku/nodejs"
    },
    {
      "url": "heroku/ruby"
    }