ibuki1124
@ibuki1124

Are you sure you want to delete the question?

If your question is resolved, you may close it.

Leaving a resolved question undeleted may help others!

We hope you find it useful!

RailsのWebpacker::Manifest::MissingEntryError が解消されない

解決したいこと

Railsで新規アプリを作成し、rails sを行い、ブラウザ上でlocalhost:3000と入力し表示したところ、その画面上ではエラーなどはありませんでしたが、/usersなどパスを入力して画面遷移をしようとすると以下の
Webpacker::Manifest::MissingEntryErrorが出てきてしまいました。
他の方の記事などを参考にし、色々試しては見たものの解決できなかったため、どなたかわかる方いらっしゃいましたらお教えいただけると幸いです。

環境

Windows 11
Visual Studio Code

Ruby 3.1.2
Rails 6.1.7.8
yarn 1.22.22
Bundler 2.5.17
sqlite3 3.46.1
node 20.16.0・18.20.4・14.21.3など変更して解決できるが試行

発生している問題・エラー

サイト上で以下の画像のように表示されます。

スクリーンショット 2024-08-17 165945.png

該当するソースコード

Gemfile
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '3.1.2'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main'
gem 'rails', '~> 6.1.7', '>= 6.1.7.8'
# Use sqlite3 as the database for Active Record
gem 'sqlite3', '~> 1.4'
# Use Puma as the app server
gem 'puma', '~> 5.0'
# Use SCSS for stylesheets
gem 'sass-rails', '>= 6'
# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker
gem 'webpacker', '~> 5.0'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.7'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use Active Model has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Active Storage variant
# gem 'image_processing', '~> 1.2'

# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.4.4', require: false

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end

group :development do
  # Access an interactive console on exception pages or by calling 'console' anywhere in the code.
  gem 'web-console', '>= 4.1.0'
  # Display performance information such as SQL time and flame graphs for each request in your browser.
  # Can be configured to work on production as well see: https://github.com/MiniProfiler/rack-mini-profiler/blob/master/README.md
  gem 'rack-mini-profiler', '~> 2.0'
end

group :test do
  # Adds support for Capybara system testing and selenium driver
  gem 'capybara', '>= 3.26'
  gem 'selenium-webdriver', '>= 4.0.0.rc1'
  # Easy installation and use of web drivers to run system tests with browsers
  gem 'webdrivers'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
package.json
{
  "name": "modal-test",
  "private": true,
  "dependencies": {
    "@babel/plugin-proposal-private-methods": "^7.18.6",
    "@babel/plugin-proposal-private-property-in-object": "^7.21.11",
    "@rails/actioncable": "^6.0.0",
    "@rails/activestorage": "^6.0.0",
    "@rails/ujs": "^6.0.0",
    "@rails/webpacker": "5.4.4",
    "turbolinks": "^5.2.0",
    "webpack": "4.46.0",
    "webpack-cli": "3.3.12"
  },
  "version": "0.1.0",
  "devDependencies": {
    "webpack-dev-server": "3"
  }
}

自分で試したこと

他の方の記事を参考にし、

rails webpacker:install

を実行すると、こちらは成功。
以下のような結果が表示されました。

success Saved 0 new dependencies.
Done in 7.59s.
Webpacker successfully installed 🎉 🍰

しかし、続けて

rails webpacker:compile

を実行すると

Compiling...
Compilation failed:
EntryModuleNotFoundError: Entry module not found: Error: Can't resolve 'babel-loader' in 'C:\Users\ivk\Rails\modal-test'
    at C:\Users\ivk\Rails\modal-test\node_modules\webpack\lib\Compilation.js:1075:31
    at C:\Users\ivk\Rails\modal-test\node_modules\webpack\lib\NormalModuleFactory.js:401:22
    at C:\Users\ivk\Rails\modal-test\node_modules\webpack\lib\NormalModuleFactory.js:130:21
    at C:\Users\ivk\Rails\modal-test\node_modules\webpack\lib\NormalModuleFactory.js:337:24
    at C:\Users\ivk\Rails\modal-test\node_modules\neo-async\async.js:2830:7
    at C:\Users\ivk\Rails\modal-test\node_modules\neo-async\async.js:6877:13
    at C:\Users\ivk\Rails\modal-test\node_modules\neo-async\async.js:2830:7
    at done (C:\Users\ivk\Rails\modal-test\node_modules\neo-async\async.js:2925:13)
    at C:\Users\ivk\Rails\modal-test\node_modules\webpack\lib\NormalModuleFactory.js:449:23
    at C:\Users\ivk\Rails\modal-test\node_modules\enhanced-resolve\lib\Resolver.js:213:14
    at C:\Users\ivk\Rails\modal-test\node_modules\enhanced-resolve\lib\Resolver.js:285:5
    at eval (eval at create (C:\Users\ivk\Rails\modal-test\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:15:1)
    at C:\Users\ivk\Rails\modal-test\node_modules\enhanced-resolve\lib\UnsafeCachePlugin.js:44:7
    at C:\Users\ivk\Rails\modal-test\node_modules\enhanced-resolve\lib\Resolver.js:285:5
    at eval (eval at create (C:\Users\ivk\Rails\modal-test\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:15:1)
    at C:\Users\ivk\Rails\modal-test\node_modules\enhanced-resolve\lib\Resolver.js:285:5
    at eval (eval at create (C:\Users\ivk\Rails\modal-test\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:27:1)
    at C:\Users\ivk\Rails\modal-test\node_modules\enhanced-resolve\lib\DescriptionFilePlugin.js:67:43
    at C:\Users\ivk\Rails\modal-test\node_modules\enhanced-resolve\lib\Resolver.js:285:5
    at eval (eval at create (C:\Users\ivk\Rails\modal-test\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:27:1)
    at C:\Users\ivk\Rails\modal-test\node_modules\enhanced-resolve\lib\ModuleKindPlugin.js:30:40
    at C:\Users\ivk\Rails\modal-test\node_modules\enhanced-resolve\lib\Resolver.js:285:5
    at eval (eval at create (C:\Users\ivk\Rails\modal-test\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:15:1)
    at C:\Users\ivk\Rails\modal-test\node_modules\enhanced-resolve\lib\Resolver.js:285:5
    at eval (eval at create (C:\Users\ivk\Rails\modal-test\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:15:1)
    at C:\Users\ivk\Rails\modal-test\node_modules\enhanced-resolve\lib\forEachBail.js:30:14
    at C:\Users\ivk\Rails\modal-test\node_modules\enhanced-resolve\lib\Resolver.js:285:5
    at eval (eval at create (C:\Users\ivk\Rails\modal-test\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:15:1)
    at C:\Users\ivk\Rails\modal-test\node_modules\enhanced-resolve\lib\UnsafeCachePlugin.js:44:7
    at C:\Users\ivk\Rails\modal-test\node_modules\enhanced-resolve\lib\Resolver.js:285:5
    at eval (eval at create (C:\Users\ivk\Rails\modal-test\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:15:1)
    at C:\Users\ivk\Rails\modal-test\node_modules\enhanced-resolve\lib\Resolver.js:285:5
    at eval (eval at create (C:\Users\ivk\Rails\modal-test\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:27:1)
    at C:\Users\ivk\Rails\modal-test\node_modules\enhanced-resolve\lib\DescriptionFilePlugin.js:67:43
    at C:\Users\ivk\Rails\modal-test\node_modules\enhanced-resolve\lib\Resolver.js:285:5
    at eval (eval at create (C:\Users\ivk\Rails\modal-test\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:16:1)
resolve 'babel-loader' in 'C:\Users\ivk\Rails\modal-test'
  Parsed request is a module
  using description file: C:\Users\ivk\Rails\modal-test\package.json (relative path: .)
    resolve as module
      C:\Users\ivk\Rails\node_modules doesn't exist or is not a directory
      C:\Users\ivk\node_modules doesn't exist or is not a directory
      C:\Users\node_modules doesn't exist or is not a directory
      C:\node_modules doesn't exist or is not a directory
      looking for modules in C:\Users\ivk\Rails\modal-test\node_modules
        using description file: C:\Users\ivk\Rails\modal-test\package.json (relative path: ./node_modules)
          using description file: C:\Users\ivk\Rails\modal-test\package.json (relative path: ./node_modules/babel-loader)
            no extension
              C:\Users\ivk\Rails\modal-test\node_modules\babel-loader doesn't exist
            .js
              C:\Users\ivk\Rails\modal-test\node_modules\babel-loader.js doesn't exist
            .json
              C:\Users\ivk\Rails\modal-test\node_modules\babel-loader.json doesn't exist
            as directory
              C:\Users\ivk\Rails\modal-test\node_modules\babel-loader doesn't exist

といったエラーが返されてしまいました。

また、publicディレクトリ下にpacksディレクトリが作成されていてその中にmanifest.jsonファイルが無いといけないという記事をお見掛けしましたが、自身のpublicディレクトリ下にはありませんでした。
こちらが原因なのではないかと考えておりますが、なぜ存在しないのかわからず解決することが出来ませんでした。

スクリーンショット 2024-08-17 164124.png

どなたかわかる方いらっしゃいましたら教えていただけないでしょうか。

追記

新規で作成したアプリでも同様のエラーが起こるか試してみようと思いrails newで作成。Homes#topを作成し、ルートパスに設定

config/routes.rb
Rails.application.routes.draw do
  root "homes#top"
end

そして

yarn add @babel/plugin-proposal-private-methods @babel/plugin-proposal-private-property-in-object

を行いWebpacker::Manifest::MissingEntryErrorが起きないようにしようとしましたが、アクセスしてみると

Started GET "/" for ::1 at 2024-08-17 17:58:39 +0900
Processing by HomesController#top as HTML
  Rendering layout layouts/application.html.erb
  Rendering homes/top.html.erb within layouts/application
  Rendered homes/top.html.erb within layouts/application (Duration: 1.0ms | Allocations: 151)
[Webpacker] Compiling...
[Webpacker] Compilation failed:
Hash: dc16521cf3e0c09994a7
Version: webpack 4.46.0
Time: 63ms
Built at: 2024/08/17 17:58:59
        Asset      Size  Chunks             Chunk Names
manifest.json  23 bytes          [emitted]

ERROR in Entry module not found: Error: Can't resolve 'babel-loader' in 'C:\Users\ivk\Rails\testApp'     



Insufficient number of arguments or no entry found.
Alternatively, run 'webpack(-cli) --help' for usage info.


  Rendered layout layouts/application.html.erb (Duration: 19859.3ms | Allocations: 17055)
Completed 500 Internal Server Error in 19870ms (Allocations: 18485)



ActionView::Template::Error (Webpacker can't find application.js in C:/Users/ivk/Rails/testApp/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:
{
  "entrypoints": {
  }
}
):
     7:     <%= csp_meta_tag %>
     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>

app/views/layouts/application.html.erb:10

同様のエラーが返されました。
しかし、今回はpublic直下にpacksディレクトリとその中にmanifest.jsonファイルが作成されていました。
スクリーンショット 2024-08-17 180509.png
manifest.jsonファイルの中にはこのような記述がありました。

public/packs/manifest.json
{
  "entrypoints": {}
}

この状態で

rails webpacker:install
rails webpacker:compile

を行うと

Everything's up-to-date. Nothing to do

と返されコンパイルは成功したのかと思いましたが、manifest.jsonファイルの中身に変更はなく再度rails sでページを開こうとすると
先程と同じエラー画面で何も変わりませんでした。

0

No Answers yet.

Your answer might help someone💌