'Rails: Webpacker::Manifest::MissingEntryError in Home#index

Webpacker::Manifest::MissingEntryError in Home#index Showing /Users/khalidhosein/Desktop/myEPKmedia/builder/khalid101/app/views/layouts/embedded_app.html.erb where line #7 raised:

Webpacker can't find hello_react.js in /Users/khalidhosein/Desktop/myEPKmedia/builder/khalid101/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:
{
  "application.js": "/packs/application-68dcba18197451fbb79e.js",
  "application.js.map": "/packs/application-68dcba18197451fbb79e.js.map"
}
Extracted source (around line #7):
5
6
7
8
9
10

    <% application_name = ShopifyApp.configuration.application_name %>
    <title><%= application_name %></title>
    <%= javascript_pack_tag 'hello_react' %>
    <%= stylesheet_link_tag 'application' %>
    <%= javascript_include_tag 'application', "data-turbolinks-track" => true %>
    <%= csrf_meta_tags %>

Rails.root: /Users/khalidhosein/Desktop/myEPKmedia/builder/khalid101

Application Trace | Framework Trace | Full Trace
app/views/layouts/embedded_app.html.erb:7:in `_app_views_layouts_embedded_app_html_erb___4509380428416253144_70127991029820'
Request
Parameters:

None

I am getting this error when trying to connect my Rails app with a React front end. I've tried researching and re-configuring files from all sources. I have also recreated manifiest.json files and packs libraries. I am following this tutorial:

https://github.com/natemacinnes/natemacinnes.github.io/blob/master/rails-5-shopify-app-setup.md

If anyone has any ideas it would be greatly appreciated as there isn't much documentation or tutorials out there going over connecting Rails Shopify API with React.

MY CODE---->https://github.com/KhalidH82/ShopifyApp-React-Rails



Solution 1:[1]

Though I am not using react, but was getting the same error on a newly created Rails 6 app. Reinstalling webpacker fixed it for me:

bundle exec rake webpacker:install

I guess it probably was some missing dependency, or a bug in an older version (I noticed webpack-dev-server version was upgraded to 3.8.1).

Solution 2:[2]

I had to same challenge when trying to set up a new Rails 6 application in Ubuntu 20.04.

When I start the rails server, and go to my browser I get the error:

Webpacker::Manifest::MissingEntryError in Books#index
Showing /home/promisepreston/dynamic_authorization/app/views/layouts/application.html.erb where line #9 raised:

Webpacker can't find application in /home/promisepreston/dynamic_authorization/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:
{

Here's how I fixed it:

The issue was that I had not setup webpacker in the Rails 6 application. Starting with Rails 6, webpacker is the default JavaScript compiler. It means that all the JavaScript code will be handled by webpacker instead of the old assets pipeline aka sprockets.

To install webpacker in your Rails 6 application simply run the command:

bundle exec rails webpacker:install

OR

rails webpacker:install

This should successfully install webpacker and all of its dependencies.

That's all.

I hope this helps

Solution 3:[3]

may be you missed to install npm install. I faced exactly same issue which you have mention. Just type npm install in your terminal or Dockerfile. I hope this issue will be solved.

$ npm install

Solution 4:[4]

This can also happen to you if you accidentally do not install webpacker. this can happen to you if you try to install webpacker with an incompatible version of Node

yarn add @rails/webpacker

notice you will get:

% yarn add @rails/webpacker
yarn add v1.22.10
[1/4] ?  Resolving packages...
[2/4] ?  Fetching packages...
error @npmcli/[email protected]: The engine "node" is incompatible with this module. Expected version "^12.13.0 || ^14.15.0 || >=16". Got "15.14.0"
error Found incompatible module.
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

you'll notice no changes will be made to your package.json file.

Because this check runs now (at the yarn install time) and not during runtime, it's easy to miss this.

If you fail to notice the yarn add has given you this error, you will think webpacker has been installed into your package.json when it hasn't.

Switching to a compatible node version and rerunning the installer fixes the problem. As it says, you need node version that is ^12.13.0 || ^14.15.0 || >=16

Solution 5:[5]

I had the same error after updating to Rails 5.1 and Webpacker 5.x

https://github.com/rails/webpacker/blob/5-x-stable/docs/integrations.md#react

The command now is bundle exec rails webpacker:install:react

Solution 6:[6]

This worked for after trying so many different solutions!

  1. yarn config set registry https://registry.npmjs.org
  2. rm yarn.lock
  3. yarn

and then install webpack again

  1. bundle exec rails webpacker:install

Github issue

Solution 7:[7]

I was stuck with this error for a long time and none of the solutions above worked for me (try them they fix the issue 95% of the time).

For me what worked was that my version of Node was too recent. I had to downgrade it !

I was : rails Rails 6.0.4.1 and node 16.9.1.

I "downgraded" node to 12.13.0 which is a stable version. And now it works perfectly.

To "downgrade" node i followed this thread : How to downgrade Node version

Solution 8:[8]

In my case, I already had Webpacker installed for my Rails 6.0 app.

The problem was that some of my custom js files had names containing dots (eg. jquery.slimscroll.js) and they didn't seem to be compiled at all.

I don't know if this is a bug or I misconfigured something but changing the file names to new ones without dots (eg. jquery_slimscroll.js) resolved the problem.

Solution 9:[9]

I had the same error on new application reinstalling the webpacker did it for me. rails webpacker:install

Solution 10:[10]

sudo bundle exec rails webpacker:install:react