Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

webpack - Can't run local Rails server: ActionView::Template::Error (Webpacker can't find application...)

I started a new project on rails (Rails 6.1.1) and when I ran the server, everything looked good (congrats you are on rails screen). I then created a static page controller, along with an index.html.erb file, and now when I run the server, I get the following error:

Webpacker can't find application in /vagrant/src/takk2/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:
{
}

Along with the following code extract:

<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
    **<%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>**
  </head>

  <body>

The bolded line is the one that raises an error (but even if I remove it, I still get the same error and "" is then marked instead.

And this is what my terminal throws out:

ActionView::Template::Error (Webpacker can't find application in /vagrant/src/takk2/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:
{
}
):
     6:     <%= csp_meta_tag %>
     7: 
     8:     <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
     9:     <%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
    10:   </head>
    11: 
    12:   <body>
  
app/views/layouts/application.html.erb:9

I browsed a ton of threads, but nothing has worked so far. Those are the things I have tried:

  • setting extract_css to false in webpacker.yml
  • updating node, reinstalling webpacker and yarn
  • removing the stylesheet_link_tag and javascript_pack_tag
  • changing my application.scss file to application.css

I read this thread that suggests to "clean all packages of node and re-install the correct described in dependencies of package.json", but I am not sure which package.jason to even look at.

Any help will be appreciated.

question from:https://stackoverflow.com/questions/65856419/cant-run-local-rails-server-actionviewtemplateerror-webpacker-cant-find

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...