LoginSignup
30
30

More than 3 years have passed since last update.

【Rails6】Webpacker::Manifest::MissingEntryErrorが出たときの対処法

Last updated at Posted at 2019-12-16

はじめに

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

エラーが出なくなりました!

30
30
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
30
30