ruby-on-rails - 生产环境中的 Rails Webpacker 编译错误

标签 ruby-on-rails webpack webpacker

环境

Rails 6.0.0
Ruby 2.6.0
Amazon Linux2
什么
enter image description here
当我部署 Rails 应用程序时,会发生此错误
ActionView::Template::Error (Webpacker can't find application in /home/web/www/eloop-regular/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.

1. 除非您使用 webpack -w,否则您希望为您的环境将 compile 的 webpacker.yml 值设置为 true或 webpack-dev-server。
我的 config/webpacker.yml 包含
production:
  <<: *default

  # Production depends on precompilation of packs prior to booting for performance.
  compile: true

  # Extract and emit a css file
  extract_css: true

  # Cache manifest.json for performance
  cache_manifest: true
2. webpack 尚未重新运行以反射(reflect)更新。
我跑
$ RAILS_ENV=production bundle exec rails webpacker:compile
3. 你错误地配置了 Webpacker 的 config/webpacker.yml 文件。
在开发环境中 webpacker 工作正常。
4. 你的 webpack 配置没有创建 list 。
manifest.json 已创建

最佳答案

当我运行预构建的 rails 6 应用程序时,我遇到了同样的问题。发现这是因为 yarn.lock 文件中的 Webpack 版本不一致。
然后当我跑
yarn add @rails/webpackerbundle update webpacker
如在此 comment 中找到的,问题解决了。

关于ruby-on-rails - 生产环境中的 Rails Webpacker 编译错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58520418/

相关文章:

ruby-on-rails - RVM + Capistrano 失败错误 bug?

ruby-on-rails - 哪个 gem 提供 Rails 控制台?

jquery - Angular 2 slider 范围 - 添加 Ion.RangeSlider 库

ruby-on-rails - 如何从 Rails 中的 npm 包加载 svg?

ruby-on-rails - 如何在代理后面使用 bundler ?

ruby-on-rails - Ubuntu 未检测到 Rails 安装

vue.js - 将 quill 模块与 vue2-editor 和 webpack 混合使用

angular cli - 添加 cdn 脚本/样式作为全局优先级

ruby-on-rails - 如何使用 Webpacker 使 jquery 可用于链轮?

css - stylesheet_pack_tag 在带有 webpacker gem 的 Rails 5.1 中找不到 app/javascript/src/application.css