0

I'm very newbie with frontend, webpack etc. Just a new app with rails 6, react-rails. I didn't change any defaults config of webpack, npm etc. I have the problem now I can't to understand where should I see to solve it.

ActionView::Template::Error (Webpacker can't find application.js in /home/ilp/www/mydogshow/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.
Your manifest contains:
{
  "entrypoints": {
  }
}
):

I already had some problem with webpacker so I upgrade gem to version 5.2.1

current config/webpacker.yml

# Note: You must restart bin/webpack-dev-server for changes to take effect

default: &default
  source_path: app/packs
  source_entry_path: entrypoints
  public_root_path: public
  public_output_path: packs
  cache_path: tmp/cache/webpacker
  webpack_compile_output: true

  # Additional paths webpack should look up modules
  # ['app/assets', 'engine/foo/app/assets']
  additional_paths: []

  # Reload manifest.json on all requests so we reload latest compiled packs
  cache_manifest: false

development:
  <<: *default
  compile: true

  # Reference: https://webpack.js.org/configuration/dev-server/
  dev_server:
    https: false
    host: localhost
    port: 3035
    public: localhost:3035
    # Inject browserside javascript that required by both HMR and Live(full) reload
    inject_client: true
    # Hot Module Replacement updates modules while the application is running without a full reload
    hmr: false
    # Inline should be set to true if using HMR; it inserts a script to take care of live reloading
    inline: true
    # Should we show a full-screen overlay in the browser when there are compiler errors or warnings?
    overlay: true
    # Should we use gzip compression?
    compress: true
    # Note that apps that do not check the host are vulnerable to DNS rebinding attacks
    disable_host_check: true
    # This option lets the browser open with your local IP
    use_local_ip: false
    # When enabled, nothing except the initial startup information will be written to the console.
    # This also means that errors or warnings from webpack are not visible.
    quiet: false
    pretty: false
    headers:
      'Access-Control-Allow-Origin': '*'
    watch_options:
      ignored: '**/node_modules/**'

test:
  <<: *default
  compile: true

  # Compile test packs to a separate directory
  public_output_path: packs-test

production:
  <<: *default

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

  # Cache manifest.json for performance
  cache_manifest: true
user1810122
  • 123
  • 2
  • 8

3 Answers3

0

To resolve this issue, try the following commands:

yarn cache clean rm -rf node_modules yarn add @babel/plugin-proposal-private-property-in-object@latest yarn add @babel/plugin-proposal-private-methods@latest yarn global cache clean yarn install bundle exec rails assets:clean RAILS_ENV=production bundle exec rails assets:precompile RAILS_ENV=production

Regards,

Ajith RAO.

0

Commands to resolve the issue:-

  • yarn cache clean.

  • rm -rf node_modules.

  • yarn add @babel/plugin-proposal-private-property-in-object@latest.

  • yarn add @babel/plugin-proposal-private-methods@latest.

  • yarn global cache clean.

  • yarn install.

  • bundle exec rails assets:clean RAILS_ENV=production.

  • bundle exec rails assets:precompile RAILS_ENV=production.

-1

Using Rails 6.1.4 and ruby 2.6.9.

This is one solution to address the problem and the one in the below link:

Webpack can't find application

Webpacker can't find application in C:/Users/[...]/[]/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. Your manifest contains: { }

Rails Webpacker Docs

This works when adding Webpacker to existing project:

Gemfile:

 ruby '2.6.9' 
 gem 'rails', '~> 6.1.4', '>= 6.1.4.4'
 gem 'webpacker' ( remove any version number from this line in gemfile ) 


run **bundle install**
run **bin/rails webpacker:install**

When creating a new app  **rails new AppName --webpack**
Rails Dev
  • 1
  • 3