Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails Webpacker compile error on Production enviorment

env

Rails 6.0.0
Ruby 2.6.0
Amazon Linux2

What

enter image description here

When I deploy my rails app this error happen

ActionView::Template::Error (Webpacker can't find application in /home/web/www/eloop-regular/public/packs/manifest.json. Possible causes:
1. You want to set webpacker.yml value of compile to true for your environment
   unless you are using the `webpack -w` or the webpack-dev-server.
2. webpack has not yet re-run to reflect updates.
3. You have misconfigured Webpacker's config/webpacker.yml file.
4. Your webpack configuration is not creating a manifest.

1. You want to set webpacker.yml value of compile to true for your environment unless you are using the webpack -w or the webpack-dev-server.

my config/webpacker.yml contains

production:
  <<: *default

  # Production depends on precompilation of packs prior to booting for performance.
  compile: true

  # Extract and emit a css file
  extract_css: true

  # Cache manifest.json for performance
  cache_manifest: true

2. webpack has not yet re-run to reflect updates.

I run

$ RAILS_ENV=production bundle exec rails webpacker:compile

3. You have misconfigured Webpacker's config/webpacker.yml file.

in development environment webpacker works correctly.

4. Your webpack configuration is not creating a manifest.

manifest.json is created

like image 204
阿吽no呼吸 Avatar asked Oct 23 '19 10:10

阿吽no呼吸


1 Answers

I have the same issue when I run pre-built rails 6 app.Found out it is because of Webpack version inconsistency in yarn.lock file. Then when I run

yarn add @rails/webpacker

bundle update webpacker

as found in this comment , issue's solved.

like image 141
Hung Om Avatar answered Oct 20 '22 00:10

Hung Om