生产环境中的 Rails Webpacker 编译错误 [英] Rails Webpacker compile error on Production enviorment

查看:41
本文介绍了生产环境中的 Rails Webpacker 编译错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Rails 6.0.0
Ruby 2.6.0
Amazon Linux2

什么

当我部署 Rails 应用程序时,会发生此错误

When I deploy my rails app this error happen

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 或 webpack-dev-server,否则您希望为您的环境将 compile 的 webpacker.yml 值设置为 true.

我的 config/webpacker.yml 包含

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.

my config/webpacker.yml contains

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 尚未重新运行以反映更新.

我跑

$ RAILS_ENV=production bundle exec rails webpacker:compile

3.您错误地配置了 Webpacker 的 config/webpacker.yml 文件.

在开发环境中 webpacker 工作正常.

3. You have misconfigured Webpacker's config/webpacker.yml file.

in development environment webpacker works correctly.

manifest.json 已创建

manifest.json is created

推荐答案

我在运行预构建的 rails 6 应用程序时遇到了同样的问题.发现是因为 yarn.lock 文件中的 Webpack 版本不一致.然后当我运行

I have the same issue when I run pre-built rails 6 app.Found out it is because of Webpack version inconsistency in yarn.lock file. Then when I run

纱线添加@rails/webpacker

捆绑更新 webpacker

在此评论中发现,问题已解决.

as found in this comment , issue's solved.

这篇关于生产环境中的 Rails Webpacker 编译错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆