.... localhost:3000 / *错误中的Webpacker :: Manifest :: MissingEntryError错误

时间:2019-12-17 17:58:53

标签: ruby-on-rails webpack vagrant webpacker

系统:

Ruby:ruby 2.6.5p114(2019-10-01版本67812)[x86_64-linux]
Rails:Rails 6.0.2
操作系统:Windows到VM(无用的ssh->到ubuntu机器:Linux vagrant-ubuntu-trusty-64 3.13.0-170-generic#220-Ubuntu SMP x86_64 GNU / Linux

当我运行rails server -b 0.0.0.0时,我可以访问localhost:3000并看到是的!您正在使用Rails!

但是当我尝试导航到localhost:3000 / say / hello时 浏览器中出现以下错误

浏览器错误:

Showing /files_on_your_computer/rails6tut/demo/app/views/layouts/application.html.erb where line #9 raised:

Webpacker can't find application in /files_on_your_computer/rails6tut/demo/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:
{
}
Extracted source (around line #9):
7
8
9
10
11
12


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

  <body>

Rails.root: /files_on_your_computer/rails6tut/demo

控制台错误:

vagrant@vagrant-ubuntu-trusty-64:/files_on_your_computer/rails6tut/demo$ rails server -b 0.0.0.0                                    => Booting Puma
=> Rails 6.0.2 application starting in development
=> Run `rails server --help` for more startup options
Puma starting in single mode...
* Version 4.3.1 (ruby 2.6.5-p114), codename: Mysterious Traveller
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://0.0.0.0:3000
Use Ctrl-C to stop
Started GET "/say/hello" for 10.0.2.2 at 2019-12-17 17:51:09 +0000
   (1.5ms)  SELECT sqlite_version(*)
Processing by SayController#hello as HTML
  Rendering say/hello.html.erb within layouts/application
  Rendered say/hello.html.erb within layouts/application (Duration: 4.3ms | Allocations: 271)
Completed 500 Internal Server Error in 115ms (ActiveRecord: 0.0ms | Allocations: 7431)



ActionView::Template::Error (Webpacker can't find application in /files_on_your_computer/rails6tut/demo/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
Started GET "/" for 10.0.2.2 at 2019-12-17 17:54:56 +0000
Processing by Rails::WelcomeController#index as HTML
  Rendering /home/vagrant/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/railties-6.0.2/lib/rails/templates/rails/welcome/index.html.erb
  Rendered /home/vagrant/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/railties-6.0.2/lib/rails/templates/rails/welcome/index.html.erb (Duration: 3.1ms | Allocations: 190)
Completed 200 OK in 6ms (Views: 5.4ms | ActiveRecord: 0.0ms | Allocations: 899)

我在heroku上看到了一些类似的问题,但是我在本地运行它,所以我有些困惑。 我正在关注带有Rails 6的敏捷Web开发。

2 个答案:

答案 0 :(得分:0)

我遇到了同样的问题,我正在使用最新版本的节点v15.2.0,并切换到较低版本的节点v14.8.0,并且webpacker可以正常工作。

参考:[https://github.com/rails/webpacker/issues/2779#issuecomment-727170370]

答案 1 :(得分:-1)

我在这里所做的只是简单地注释掉第9行。

8:<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>

9:<%#= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>