【Rails6】Webpacker::Manifest::MissingEntryErrorが出たときの対処法
はじめに
Rails6ではwebpackerが標準サポートとなりました。webpakerのインストールにはパッケージマネージャーであるyarnを使用します。そのため,yarnが正常にインストールされていない環境でwebpakerをインストールしようとするとエラーが生じます。
・yarnの「パッケージのバージョンが不一致」によるエラーの解決方法について説明します。
その他のエラーに関しては,@NaokiIshimuraさんの以下の記事で詳しく説明してくれています。
・Rails6 開発時につまづきそうな webpacker, yarn 関係のエラーと解決方法
開発環境
Rails 6.0.1
エラー
rails webpacker:install
を実行後 log には "Webpacker successfully installed" と表示されていたのですが,javascriptを使用するページにローカルサーバーでアクセスすると以下のようなエラーが出ました。
ActionView::Template::Error (Webpacker can't find application in /Users/username/projects/my_app/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:
{
}
):
7: <meta name="viewport" content="width=device-width,initial-scale=1">
8:
9: <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
10: <%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
11: </head>
12:
13: <body>
以下のコマンドをRailsアプリのディレクトリ内で実行しましたがうまくいかず...
yarn # 解決しなかった
yarn install # 解決しなかった
yarn upgrade # 解決しなかった
解決方法
ホームディレクトリ内でyarnを最新のヴァージョンに更新
brew install yarn
その後,アプリディレクトリ内で
rails install yarn
エラーが出なくなりました!
Author And Source
この問題について(【Rails6】Webpacker::Manifest::MissingEntryErrorが出たときの対処法), 我々は、より多くの情報をここで見つけました https://qiita.com/masatwork/items/1b5d190cc76f5eeffbb7著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .