ЯoomeR

プログラミング~実装とエラー解決と、時々、AI~

Webpacker::Manifest::MissingEntryError[Windows]解消手順

エラー画像

エラー文

Webpacker::Manifest::MissingEntryError in Properties#index
Showing C:/Users/ユーザー名/アプリ名/app/views/layouts/application.html.erb where line #9 raised:

Webpacker can't find application.js in C:/Users/ユーザー名/アプリ名/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:
{
}

解決方法

step1 Webpackerのインストール

rails webpacker:install

step 1-1

error Command "webpack" not found.

もし上記のエラーが出る場合は、GemfileのWebpackerのバージョンを上げよう

gem 'webpacker', '~> 4.0' 
↓
gem 'webpacker', '~> 5.0' 

step2

bundle install
rails webpacker:install
rails webpacker:compile

step2-1

Error: error:0308010C:digital envelope routines::unsupported
...
code: 'ERR_OSSL_EVP_UNSUPPORTED'
}

Node.js v18.14.0

上記のエラーが出る場合は、node.jsのバージョンを変更する必要がある。

step2-2 nvmをインストールする

https://github.com/coreybutler/nvm-windows/releases

こちらから「nvm-setup.zip」をダウンロードする。

ダウンロードが完了したら、解凍してexeファイルを実行する

step2-3 node.jsの別バージョンをインストールする

nvm install 14

最初の2桁だけを入力する

nvm list available

上記コマンドでインストールできるバージョン一覧を確認できるが、それより下の数字のバージョンも実はインストール可能。

nvm ls

でインストールされているバージョンを確認し、

nvm use 14.21.3

でバージョンを変更する

ここまで完了したら改めて

rails webpacker:compile

を実行する

step3 rails sの再実行

これで当初のエラーは解決できる。