webpacker: heroku: error Command "webpack" not found.
Hello,
I spent the day migrating an old rails 4 app with the gem react_rails to a new rails 5.1
app with webpacker
.
Everything works perfectly well, except when I try to deploy the app on heroku.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 44 (14 by maintainers)
Commits related to this issue
- Removing engines key, we'll put it back when Scalingo uses both nodejs and ruby buildpacks (https://github.com/rails/webpacker/issues/512) — committed to betagouv/place-des-entreprises by ArnoHolo 7 years ago
- fix: move depenendecies to fix rake assets:precompile It seems that rails webpacker expects dependencies like webpack and babel presets to be in dependencies versus devDependencies: https://github.co... — committed to mojotech/helios2 by cbarber 5 years ago
- Regenerate binstubs to fix error: https://github.com/rails/webpacker/issues/512 — committed to pei-liu/codenames by pei-liu a year ago
@tchret No, I was just checking if thatโs overriding the default one. The default ruby buildpacks now takes care of this with webpacker gem. BTW, could you please add these two buildpacks and try deploying again -
I just ran into this in a brand new Rails 6.1.3 app. None of the solutions in this thread worked for me. What did work was adding webpacker to
package.json
Then I did
yarn install
and committed the changes in bothpackage.json
andyarn.lock
. Then I pushed to heroku and deployment worked.Running
heroku buildpacks:add --index 1 heroku/nodejs
fixed the errorCommand "webpack" not found
for me.@tchret The above command wonโt work, try this:
@gauravtiwari: haaaa the nodejs one was missing ๐ I guess it was because the production setup was an old one (created under rails 4)
Thank you so much man ๐๐ผ
Hello ๐ I maintain the Ruby buildpack. The ruby buildpack provides both node and yarn, though you can specify a specific version if you desire by also using the nodejs buildpack.
One thing to watch out for here with this specific error is that the
webpack
command is provided by your application, usually atbin/webpack
. Make sure it is good, you might need to re-generate binstubs:Yes, updating a rails app from 6.1 to 7.0 gives the same error, the only thing that seems to work is
heroku buildpacks:add --index 1 heroku/nodejs
. This is despite having webpack available when I runwhich webpack
in heroku.Where did you run that command - from your local terminal, or in heroku?
@schneems : I tried
heroku run bash
andwhich webpack
and do not see anything . How do I set path on heroku?Seems like the yarn install task is invoked but there is no yarn binstub present since you were using Rails 4 earlier. Please regenerate them -
bundle install --binstubs