DEV Community

Cover image for Rails 6: Webpacker::Manifest::MissingEntryError
Dani Schuhman
Dani Schuhman

Posted on

Rails 6: Webpacker::Manifest::MissingEntryError

Error handling can either be something that's incredibly aggravating, or satisfying as a developer. Errors inevitably happen, but sometimes even after falling down a google rabbit hole that leads to questions on Stackoverflow, to github threads, can often lead to even more aggravation and not an actual solution. Especially when there is no forward momentum in the errors. At least when an error changes to something new, you know you've done something right. Maybe.

I'm going to try and walk through a solution to the Rails 6 Webpacker::Manifest::MissingEntryError, in the hope that one person stumbles across this in the future and it helps.

After setting up a new project in Rails, when attempting to fire up the development server, I was automatically hit with this error:

Webpacker can't find application.js in /Users/danischuhman/Development/code/photo_app/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:
Enter fullscreen mode Exit fullscreen mode

What the error means is that Webpacker can't find the application, and is failing at square one to compile. None of the files that are needed in order for Webpacker to run properly, are being generated. I don't know precisely why this happens, or where there is a failure to cause this issue, just that it happens. And it's annoying.

Some of the github threads talked about aliasing a css file, and altering the <%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %> tag within application.html.erb file. Other workarounds talked about removing the tag entirely. Removing the tag allows everything to run properly, except, it doesn't solve the issue and leads to further errors down the road, which really isn't the best way to handle debugging. Others had solutions that worked for some people, but did not for me.

The solution, which I only came to after discussing it with a good friend, and much more experienced engineer, is pretty straightforward.

First thing, is to run rails webpacker:install and overwrite the existing webpacker.yml file.

Next is to delete the node_modules folder in your repo, and if it exists, the public/packs folder. In my case, my public/packs folder wasn't even being generated, so there was nothing to delete there.

Then run yarn install, bundle, and then rails webpacker:install, overwriting any files it suggests you to overwrite.

Hopefully, if everything has then been installed properly, when you fire up rails s your application should open to the main page, and there should no longer be an error. Which, I hope if you've found this blog post, is precisely what's happened for you.

In the future, when building my next Rails App, I will follow this order of operations, just to make sure everything is generated properly and to hopefully avoid the error:

bundle install
rails db:migrate
rails webpacker:install
yarn install
rails server
Enter fullscreen mode Exit fullscreen mode

For the time being, I'm glad to have found a solution that works, and hopefully know in the future how to work around it, should the problem arise again.

Here are some links to discussion of this particular issue, to see just some of the solutions offered up by other engineers.

github issue 1494

github issue 1523

stackoverflow

stackoverflow

github issue 2071

Discussion (0)