Deploying to Heroku: Command "webpack" not found

When I try to deploy to Heroku, I receive this error. Command "webpack" not found. I’ve tried solutions like looking into yarn and installing a package.json in the root. I’m not completely sure but I feel the problem could lie in my package.json needing additional information regarding ‘webpack’.

here is the error in the console:

Rails version :

Ruby version : 2.7.1

I remember I was fighting with this, but can not remember now how I resolved it. What is your build pack?

Try add a nodeJS buildpack (make sure it is above Ruby buildpack) in Heroku dashboard -> your app -> Settings -> Buildpack



Has anyone managed to solve this? I’m having a similar issue locally, yarn install is successful, but webpack is not found when starting rails server.

I’m having this same issue still. I’ve tried adding the build packs, I’ve tried without them. I’ve tried moving dependencies from devDependencies, no dice there either. When I run heroku run bash, and run which webpack, I get nothing. I’m seeing this issue all over github, but no solutions seem to exist that work for everyone.

Hey, I never resolved the issue, just had to recreate the app, copy all the code and try redeploying it. It worked out the second time.

Just thought I’d document what worked for me here.

in package.json

  "dependencies": {
    "@rails/webpacker": "5.1.1",
  "engines": {
    "node": "14.X"

I changed my heroku config with this

heroku config:set NPM_CONFIG_PRODUCTION=false YARN_PRODUCTION=false

apparently that keeps some dependencies around for a little longer so that rails can do its thing.

Then I ran into the problem you had. So I added the heroku/nodejs build pack to the build packs as per @soulchild above. (Thanks @soulchild !)

1 Like

These three tips solved the issues for me (upgrading from Rails

  • package.json must contain web packer (see @Wobbles example)
  • Make sure the build packs are configured
  • Run “yarn” locally to update yarn.lock