本文介绍了Webpacker在manifest.json Heroku生产中找不到application.js的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在heroku上的应用出现了webpacker问题.

I'm having a webpacker issue with my app on heroku.

日志:

ActionView::Template::Error (Webpacker can't find application.js in /app/public/packs/manifest.json. Possible causes:
2018-07-04T18:47:08.192729+00:00 app[web.1]: 1. You want to set webpacker.yml value of compile to true for your environment
2018-07-04T18:47:08.192730+00:00 app[web.1]:    unless you are using the `webpack -w` or the webpack-dev-server.
2018-07-04T18:47:08.192733+00:00 app[web.1]: 2. webpack has not yet re-run to reflect updates.
2018-07-04T18:47:08.192734+00:00 app[web.1]: 3. You have misconfigured Webpacker's config/webpacker.yml file.
2018-07-04T18:47:08.192735+00:00 app[web.1]: 4. Your webpack configuration is not creating a manifest.
2018-07-04T18:47:08.192737+00:00 app[web.1]: Your manifest contains:
2018-07-04T18:47:08.192738+00:00 app[web.1]: {
2018-07-04T18:47:08.192740+00:00 app[web.1]: }
2018-07-04T18:47:08.192741+00:00 app[web.1]: ):

我有一个manifest.json文件,其中确实包含application.js:

I have a manifest.json file which does contain application.js:

{
  "application.css": "/packs/application-c922057d6b9db34084d6e52c6f32baa9.css",
  "application.css.map": "/packs/application-c922057d6b9db34084d6e52c6f32baa9.css.map",
  "application.js": "/packs/application-ab33c1479403810d7775.js",
  "application.js.map": "/packs/application-ab33c1479403810d7775.js.map"
}

有趣的是日志的最后一行:

It's interesting the final line in the log:

2018-07-04T18:47:08.192737+00:00 app[web.1]: Your manifest contains:
2018-07-04T18:47:08.192738+00:00 app[web.1]: {
2018-07-04T18:47:08.192740+00:00 app[web.1]: }

json中的格式是否不正确?

Is the formatting in the json wrong somehow?

我尝试运行bundle exec rails webpacker:compile很好,而且我还更新了binstub bundle exec rails webpacker:binstubs,在推送到Heroku之后似乎都没有任何改变.

I've tried running bundle exec rails webpacker:compile which was fine, and I've also updated the binstub bundle exec rails webpacker:binstubs, neither seem to have made a difference after pushing to Heroku.

我还能尝试什么?

推荐答案

  • 我删除了文件夹node_modules
  • 然后在终端yarn add @rails/webpacker@next
  • 然后bundle exec rails webpacker:install
    • I removed folder node_modules
    • then on terminal yarn add @rails/webpacker@next
    • then bundle exec rails webpacker:install
    • 在那之后,它是固定的

      这篇关于Webpacker在manifest.json Heroku生产中找不到application.js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-23 18:31