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

Top comments (7)

Collapse
 
lcobell profile image
Logan CoBell

I had the same error, while your solution didn't work for me one of my instructors sent me another fix. In bin/server

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
parentdir="$(dirname "$DIR")"
pid="$parentdir/tmp/pids/server.pid"
if [ -f $pid ]; then
  rm $pid
fi
fuser -k -n tcp 3000
export NODE_OPTIONS=--openssl-legacy-provider && rails server -b 0.0.0.0
Enter fullscreen mode Exit fullscreen mode

I can now get back to work!

Collapse
 
im3shn profile image
Thrishan Anbazhagan

what do you mean by bin/server?

Collapse
 
collinjilbert profile image
Collin

Thanks for writing this post, it definitely helped get me back up and running. The only thing I had to do differently was change the version of node I was running from the latest to the latest stable version that node recommended for most users. Once I set my version on my machine to that, I followed these steps and it works! Just wanted to share that additional piece and say thanks for writing this post!

Collapse
 
dani8439 profile image
Dani Schuhman

I'm really glad it helped! I've run into the problem a few times now, and all the scouring on the web didn't actually help. And that's so frustrating!

Collapse
 
franklinvv profile image
Franklin Vidal

Downgrading the version of node to 16 solve my problem.

Collapse
 
reiz profile image
Robert Reiz

That might work for me as well. On localhost I have Node 16 and it works. On the server Node 18 and it doesn't. Thanks for the hint!

Collapse
 
reiz profile image
Robert Reiz

Not that easy to pin the Node version on an Alpine Docker Image. I guess I will just migrate from Rails 6 to Rails 7 and get rid of Webpack completely.