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

IT技术 ruby-on-rails reactjs webpacker
2021-05-23 20:29:10

Webpacker::Manifest::MissingEntryError in Home#index 显示 /Users/khalidhosein/Desktop/myEPKmedia/builder/khalid101/app/views/layouts/embedded_app.html.erb,其中第 7 行提出:

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

尝试将我的 Rails 应用程序与 React 前端连接时出现此错误。我已经尝试从所有来源研究和重新配置文件。我还重新创建了 manifyingt.json 文件和包库。我正在关注本教程:

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

如果有人有任何想法,我们将不胜感激,因为没有太多的文档或教程介绍如何将 Rails Shopify API 与 React 连接起来。

我的代码----> https://github.com/KhalidH82/ShopifyApp-React-Rails

4个回答

虽然我没有使用 react,但在新创建的 Rails 6 应用程序上遇到了同样的错误。重新安装 webpacker 为我修复了它:

bundle exec rake webpacker:install

我想这可能是某些缺少的依赖项,或者旧版本中的错误(我注意到webpack-dev-server版本已升级到3.8.1)。

尝试Ubuntu 20.04 中设置新的Rails 6应用程序时,我遇到了同样的挑战

当我启动 rails 服务器并转到我的浏览器时,我收到错误消息:

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:
{

这是我修复它的方法

问题是我没有webpackerRails 6应用程序中设置。Rails 6开始webpacker是默认的 JavaScript 编译器。这意味着所有 JavaScript 代码都将由webpacker旧的资产管道 aka来处理sprockets

webpacker在 Rails 6 应用程序中安装,只需运行以下命令:

bundle exec rails webpacker:install

或者

rails webpacker:install

这应该成功安装webpacker及其所有依赖项。

就这样。

我希望这有帮助

可能是你错过了安装npm install我遇到了你提到的完全相同的问题。只需输入npm install您的终端或Dockerfile. 我希望这个问题会得到解决。

$ npm install

我被这个错误困扰了很长时间,上面的解决方案都没有对我有用(尝试它们,它们在 95% 的时间内解决了问题)。

对我来说,有效的是我的Node版本太新了。我不得不降级它!

我是:rails Rails 6.0.4.1 和节点16.9.1。

我将节点“降级”到 12.13.0,这是一个稳定版本。现在它可以完美运行。

为了“降级”节点,我遵循了这个线程:如何降级节点版本