Rails 6.0.0
Ruby 2.6.0
Amazon Linux2
当我部署我的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.
我的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
我跑
$ RAILS_ENV=production bundle exec rails webpacker:compile
在开发环境中webpacker工作正常。
创建清单. json
当我运行预构建的rails 6应用程序时,我也遇到了同样的问题。发现这是因为yarn. lock文件中的Webpack版本不一致。然后当我运行时
yarn添加@rails/webpacker
捆绑更新webpacker
如本评论所示,问题已解决。
删除Webpacker:
rm -rf bin/webpack*
安装Webpacker:
rails webpacker:install
由Webpacker在生产
模式下编译:
RAILS_ENV=production rails webpacker:compile
关于这个
我也有同样的问题。只需在开发环境中运行:
rails webpacker:install
如果您使用Docker,请运行:
docker exec rails-app-name rails webpacker:install