LoginSignup
1
1

More than 1 year has passed since last update.

【Rails】Webpacker::Manifest::MissingEntryErrorの対処方法

Last updated at Posted at 2023-01-11

0. 環境

macOS Ventura 13.1
Ruby on Rails 6.0.5
Ruby 2.7.7
yarn 1.22.19

1. エラー発生状況

Railsでアプリを作成し、http://localhost:3000/(コントローラ名)/1にアクセスしたところ、次のエラーが発生した。

view
Webpacker::Manifest::MissingEntryError

Webpacker can't find application in /Users/username/myapp/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:
...

2-1. 対処方法①

こちらの記事を参考にし、次のコマンドを実行した。

zsh
rails webpacker:install
rails webpacker:compile

webpackerのインストールができたと思いきや、エラーが発生していた。

zsh
error /Users/username/myapp/node_modules/node-sass: Command failed.
zsh
error Command "webpack" not found.

2-2. 対処方法②

こちらの記事を参考にし、以下の手順を実施した。

1. gem 'webpacker'のバージョンを上げる

Gemfile
-  gem 'webpacker', '~> 4.0'
+  gem 'webpacker', '~> 5.0'

2. yarn.lockを削除する

3. package.jsonに"@rails/webpacker"を追記する

package.json
{
  "dependencies": {
+   "@rails/webpacker": "5.4.3"
  }
}

4. yarn installを実行する

zsh
yarn install

5. yarn add node-sassを実行する

zsh
yarn add node-sass

6. bundle installを実行する

zsh
bundle install

2-3. 対処方法③

再度以下のコマンドを実行した。

zsh
rails webpacker:install
rails webpacker:compile

その後、rails sを実行し、http://localhost:3000/(コントローラ名)/1にアクセスすると、正常にビューが表示された。

1
1
0

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
1
1