Webpacker 4.2 can't find application in /app/public/packs/manifest.json heroku

It looks like there's no application.css in your manifest.json which means you might not be importing any css from within your Webpack javascript files.

If that's all true, then you can fix the error in production by one of the following:

  • Quick (temporary) fix: Add extract_css: false to your production block in config/webpacker.yml (which would mimic your local environments)
  • If you don't want to compile css with Webpacker: Remove <%= stylesheet_pack_tag 'application' %> from your application layout
  • If you want to compile some css with Webpacker: Import at least one css file from your Webpack javascript

If you are using Rails 6+ with webpacker then due to the latest rails 6 update the both javascript and css files are moved under app/javascript instead of app/assets.

app/javascript:
  ├── packs:
  │   # only webpack entry files here
  │   └── application.js
  └── src:
  │   └── application.css
  └── images:
      └── logo.svg

But if you have upgraded from older version to new version but still want to compile CSS from app/assets/stylesheets folder then follow the below tweaks:

  1. update the below in config/webpacker.yml for webpack to include app/assets in the resolved path.
// config/webpacker.yml

resolved_paths: ['app/assets']
  1. copy below line to app/javascript/packs/application.js.
// app/javascript/packs/application.js

import 'stylesheets/application'

This should fix your CSS compilation issue when you run bin/webpack-dev-server.


I was getting the same error on my local instance also.

After trying out a lot of workarounds, the following steps worked for me

bundle exec rails webpacker:install

Though this command was failing with the following error

gyp: No Xcode or CLT version detected! gyp ERR! configure error gyp ERR! stack Error: gyp failed with exit code: 1 gyp ERR! stack at ChildProcess.onCpExit (/Users//Documents/Ruby/udemy/test/alpha-blog/alpha-blog/node_modules/node-gyp/lib/configure.js:345:16) gyp ERR! stack at ChildProcess.emit (node:events:376:20) gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:284:12) gyp ERR! System Darwin 19.6.0 gyp ERR! command "/usr/local/Cellar/node/15.5.0/bin/node" "/Users//Documents/Ruby/udemy/test/alpha-blog/alpha-blog/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library=" gyp ERR! cwd /Users/***/Documents/Ruby/udemy/test/alpha-blog/alpha-blog/node_modules/node-sass gyp ERR! node -v v15.5.0 gyp ERR! node-gyp -v v3.8.0 gyp ERR! not ok

To correct the issue I used the following stack overflow answer (on macOS catalina)

https://stackoverflow.com/a/60860951/5876113

Then I ran the following command

bundle exec rails webpacker:install

After doing above steps I didn't get the error again. Please verify if this works for you as you are facing the issue on Heroku deployment.