0
0

Webpacker::Manifest::MissingEntryErrorの解決方法

Last updated at Posted at 2023-10-01

【開発環境】

Ruby 2.7.5
Rails 6.1.7.6

どういう時にエラーが発生したか

  1. Railsで新規アプリケーションを実装した際、users_controller.rbを新規作成
  2. indexアクションを定義後、app > views > index.html.erbを新規作成
  3. rails sコマンドで立ち上げた際に、以下のエラーが作成した。

※以下のようなエラーのキャプチャ
スクリーンショット 2023-10-02 6.16.30.png

エラー解決のためにやったこと

[Webpacker::Manifest::MissingEntryErrorが発生]https://qiita.com/kndknd/items/18187f1c2199651d08d5
上記のサイトでは以下の2コマンドでOKとのこと

rails webpacker:install
rails webpacker:compile

だが、rails webpacker:compileでエラーになってしまった。
調査すると、こちらのパッケージ@babel/plugin-proposal-private-property-in-objectがインポートされていますが、package.jsonに記述がないとエラーになってしまうとのこと

Compiling...
Compilation failed:
warning ../../package.json: No license field
node:internal/process/promises:279
            triggerUncaughtException(err, true /* fromPromise */);
            ^

Error: [BABEL]: --- PLACEHOLDER PACKAGE ---
This @babel/plugin-proposal-private-property-in-object version is not meant to
be imported. Something is importing
@babel/plugin-proposal-private-property-in-object without declaring it in its
dependencies (or devDependencies) in the package.json file.
Add "@babel/plugin-proposal-private-property-in-object" to your devDependencies
to work around this error. This will make this message go away.
 (While processing: /home/ec2-user/environment/sample/node_modules/@babel/plugin-proposal-private-property-in-object/lib/index.js)
    at Object.<anonymous> (/home/ec2-user/environment/sample/node_modules/@babel/plugin-proposal-private-property-in-object/lib/index.js:28:7)
    at Module._compile (/home/ec2-user/environment/sample/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1250:10)
    at Module.load (node:internal/modules/cjs/loader:1074:32)
    at Function.Module._load (node:internal/modules/cjs/loader:909:12)
    at Module.require (node:internal/modules/cjs/loader:1098:19)
    at require (/home/ec2-user/environment/sample/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
    at loadPartialConfigAsync (/home/ec2-user/environment/sample/node_modules/@babel/core/lib/config/index.js:34:85)
    at Object.<anonymous> (/home/ec2-user/environment/sample/node_modules/babel-loader/lib/index.js:126:26)

package.jsonに以下の設定を追加する

  "devDependencies": {
    "@babel/plugin-proposal-private-methods": "^7.18.6",
    "@babel/plugin-proposal-private-property-in-object": "^7.21.0",
    "webpack-dev-server": "^3"
  }

npm installを再度実行する

npm install

rails webpacker:compileを再度実行する

rails webpacker:compile

エラーが消えてページを表示することができた!

スクリーンショット 2023-10-02 6.40.55.png

【まとめ】 エラー解決にあたり感じたこと、考えたこと

エラー文を見て解決できてよかったと思いましたが、英語の読解力と検索力を上げていきたいと思いました。まだまだ勉強中ですが、Webpackの理解を深めていきたいと思いました。
何かご指摘がありましたらお願いします!ここまで読んで下さり、ありがとうございました!

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