# Deploying to Heroku: Command "webpack" not found

**URL:** <https://discuss.rubyonrails.org/t/deploying-to-heroku-command-webpack-not-found/76409>\
**Category:** Uncategorized\
**Created:** [October 28, 2020, 6:42pm UTC](https://discuss.rubyonrails.org/t/deploying-to-heroku-command-webpack-not-found/76409 "2020-10-28T18:42:49Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![dwayne26](https://avatars.discourse-cdn.com/v4/letter/d/ecb155/32.png) [@dwayne26](https://discuss.rubyonrails.org/u/dwayne26)\
**Post date:** [October 28, 2020, 6:42pm UTC](https://discuss.rubyonrails.org/t/deploying-to-heroku-command-webpack-not-found/76409/1 "2020-10-28T18:42:49Z")

</div>

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:

 ![Screen Shot 2020-10-28 at 1.28.13 PM](https://global.discourse-cdn.com/rubyonrails/original/2X/c/c90b2cd466b33b2fa93d97ef5151f1b38b2e3e5d.png)

**Rails version** :6.0.3.2

**Ruby version** : 2.7.1

---

<div class="post-metadata">

**Author:** ![kmitov](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/kmitov/32/1878_2.png) [@kmitov](https://discuss.rubyonrails.org/u/kmitov)\
**Post date:** [October 31, 2020, 4:31pm UTC](https://discuss.rubyonrails.org/t/deploying-to-heroku-command-webpack-not-found/76409/2 "2020-10-31T16:31:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![soulchild](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/soulchild/32/2396_2.png) [@soulchild](https://discuss.rubyonrails.org/u/soulchild)\
**Post date:** [November 3, 2020, 8:42am UTC](https://discuss.rubyonrails.org/t/deploying-to-heroku-command-webpack-not-found/76409/3 "2020-11-03T08:42:40Z")

</div>

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

![buildpack](https://global.discourse-cdn.com/rubyonrails/original/2X/0/03fe30790edac6c48300af1ec42315f5463a0807.png)

---

<div class="post-metadata">

**Author:** ![s0kil](https://avatars.discourse-cdn.com/v4/letter/s/ee59a6/32.png) [@s0kil](https://discuss.rubyonrails.org/u/s0kil)\
**Post date:** [November 17, 2020, 9:35pm UTC](https://discuss.rubyonrails.org/t/deploying-to-heroku-command-webpack-not-found/76409/4 "2020-11-17T21:35:15Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jakehockey10](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/jakehockey10/32/2618_2.png) [@jakehockey10](https://discuss.rubyonrails.org/u/jakehockey10)\
**Post date:** [November 30, 2020, 1:03am UTC](https://discuss.rubyonrails.org/t/deploying-to-heroku-command-webpack-not-found/76409/5 "2020-11-30T01:03:48Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dwayne26](https://avatars.discourse-cdn.com/v4/letter/d/ecb155/32.png) [@dwayne26](https://discuss.rubyonrails.org/u/dwayne26)\
**Post date:** [November 30, 2020, 5:01pm UTC](https://discuss.rubyonrails.org/t/deploying-to-heroku-command-webpack-not-found/76409/6 "2020-11-30T17:01:05Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Wobbles](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/wobbles/32/2706_2.png) [@Wobbles](https://discuss.rubyonrails.org/u/Wobbles)\
**Post date:** [December 18, 2020, 9:58pm UTC](https://discuss.rubyonrails.org/t/deploying-to-heroku-command-webpack-not-found/76409/7 "2020-12-18T21:58:22Z")

</div>

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

in package.json

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

```

I changed my heroku config with this

```ruby
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 !)

---

<div class="post-metadata">

**Author:** ![pebneter](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/pebneter/32/3124_2.png) [@pebneter](https://discuss.rubyonrails.org/u/pebneter)\
**Post date:** [March 14, 2021, 7:54pm UTC](https://discuss.rubyonrails.org/t/deploying-to-heroku-command-webpack-not-found/76409/8 "2021-03-14T19:54:46Z")

</div>

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

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

---

<div class="post-metadata">

**Author:** ![cesc1989](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/cesc1989/32/1193_2.png) [@cesc1989](https://discuss.rubyonrails.org/u/cesc1989)\
**Post date:** [May 14, 2021, 9:01pm UTC](https://discuss.rubyonrails.org/t/deploying-to-heroku-command-webpack-not-found/76409/9 "2021-05-14T21:01:11Z")

</div>

Doing what @soulchild recommended was the thing that fixed for me.

---

<div class="post-metadata">

**Author:** ![Romaguera](https://avatars.discourse-cdn.com/v4/letter/r/eb9ed0/32.png) [@Romaguera](https://discuss.rubyonrails.org/u/Romaguera)\
**Post date:** [July 16, 2021, 4:55am UTC](https://discuss.rubyonrails.org/t/deploying-to-heroku-command-webpack-not-found/76409/10 "2021-07-16T04:55:34Z")

</div>

Thanks for the information. I will try to figure it out for more. Keep sharing such informative post keep suggesting such post.

[My Lowes Life](https://www.myloweslife.run/)

---

<div class="post-metadata">

**Author:** ![theinbetweens](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/theinbetweens/32/4437_2.png) [@theinbetweens](https://discuss.rubyonrails.org/u/theinbetweens)\
**Post date:** [December 16, 2021, 6:17pm UTC](https://discuss.rubyonrails.org/t/deploying-to-heroku-command-webpack-not-found/76409/11 "2021-12-16T18:17:35Z")

</div>

I had this problem when upgrading from an older version of Rails. The issue for me was there wasn’t a bin/yarn script. Just generate a new rails project and copy the yarn file across to your site.

As described here

> **[How to fix "Command "webpack" not found"](https://makandracards.com/makandra/493721-how-to-fix-command-webpack-not-found)**
>
> I just ran into this deployment error after switching from the asset pipeline to webpack:
> 01:05 deploy:assets:precompile
> 01 bundle exec rake assets:precompile
> 01 Compiling...
> 01 Compilation failed:
> 01 yarn run v1.22.5
> 01...

---

<div class="post-metadata">

**Author:** ![TCCDevelopment](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/tccdevelopment/32/5124_2.png) [@TCCDevelopment](https://discuss.rubyonrails.org/u/TCCDevelopment)\
**Post date:** [May 1, 2022, 6:23pm UTC](https://discuss.rubyonrails.org/t/deploying-to-heroku-command-webpack-not-found/76409/12 "2022-05-01T18:23:55Z")

</div>

Doing what @Soulchild suggested also helped me with deploying an application with ruby ‘3.0.2’ and ‘rails’, ‘~\> 7.0.2.3’

---

<div class="post-metadata">

**Author:** ![ShawnAukstak](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/shawnaukstak/32/5533_2.png) [@ShawnAukstak](https://discuss.rubyonrails.org/u/ShawnAukstak)\
**Post date:** [July 22, 2022, 5:32pm UTC](https://discuss.rubyonrails.org/t/deploying-to-heroku-command-webpack-not-found/76409/13 "2022-07-22T17:32:39Z")

</div>

@soulchild’s recommendation also worked, the order of Buildpacks is important (heroku/nodejs) first.
