webpackerのエラーを直したい

実現したいこと

webpackerインストールのちコンパイルができないためできるようにしたい。

発生している問題・分からないこと

webpackeインストールのち,rails webpacker:compileを実行しようとしたのですが,うまくできず,エラーメッセージが出てきてしまっている。

Webpacker successfully installed 🎉 🍰

エラーメッセージ

error

1# rails webpacker:compile 2Warning: you are using an unstable release of Node.js (v19.9.0). If you encounter issues with Node.js, consider switching to an Active LTS release. More info: https://docs.npmjs.com/try-the-latest-stable-version-of-node 3Compiling... 4Compilation failed: 5Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema. 6 - configuration.entry should be an non-empty object. 7 -> Multiple entry bundles are created. The key is the chunk name. The value can be a string or an array. 8 9ブラウザ側のエラー 10 11Webpacker::Manifest::MissingEntryError in Posts#index 12Showing /app/app/views/layouts/application.html.erb where line #16 raised: 13 14Webpacker can't find application.js in /app/public/packs/manifest.json. Possible causes: 151. You want to set webpacker.yml value of compile to true for your environment 16 unless you are using the `webpack -w` or the webpack-dev-server. 172. webpack has not yet re-run to reflect updates. 183. You have misconfigured Webpacker's config/webpacker.yml file. 194. Your webpack configuration is not creating a manifest. 20Your manifest contains: 21{ 22} 23Extracted source (around line #16): 2414 2515 2616 2717 2818 2919 30 31 32 <%= stylesheet_pack_tag 'application', media: 'all' %> 33 <%= javascript_pack_tag "application", "data-turbo-track": "reload", defer: true %> 34 </head> 35 36 <body>

該当のソースコード

config/webpacker.yml

1# Note: You must restart bin/webpack-dev-server for changes to take effect 2 3default: &default 4 source_path: app/javascript 5 source_entry_path: entry 6 public_root_path: public 7 public_output_path: packs 8 cache_path: tmp/cache/webpacker 9 webpack_compile_output: true 10 11 # Additional paths webpack should lookup modules 12 # ['app/assets', 'engine/foo/app/assets'] 13 additional_paths: [] 14 15 # Reload manifest.json on all requests so we reload latest compiled packs 16 cache_manifest: false 17 18 # Extract and emit a css file 19 extract_css: false 20 21 static_assets_extensions: 22 - .jpg 23 - .jpeg 24 - .png 25 - .gif 26 - .tiff 27 - .ico 28 - .svg 29 - .eot 30 - .otf 31 - .ttf 32 - .woff 33 - .woff2 34 35 extensions: 36 - .mjs 37 - .js 38 - .sass 39 - .scss 40 - .css 41 - .module.sass 42 - .module.scss 43 - .module.css 44 - .png 45 - .svg 46 - .gif 47 - .jpeg 48 - .jpg 49 50development: 51 <<: *default 52 compile: true 53 54 # Reference: https://webpack.js.org/configuration/dev-server/ 55 dev_server: 56 https: false 57 host: localhost 58 port: 3035 59 public: localhost:3035 60 hmr: false 61 # Inline should be set to true if using HMR 62 inline: true 63 overlay: true 64 compress: true 65 disable_host_check: true 66 use_local_ip: false 67 quiet: false 68 pretty: false 69 headers: 70 'Access-Control-Allow-Origin': '*' 71 watch_options: 72 ignored: '**/node_modules/**' 73 74 75test: 76 <<: *default 77 compile: true 78 79 # Compile test packs to a separate directory 80 public_output_path: packs-test 81 82production: 83 <<: *default 84 85 # Production depends on precompilation of packs prior to booting for performance. 86 compile: false 87 88 # Extract and emit a css file 89 extract_css: true 90 91 # Cache manifest.json for performance 92 cache_manifest: true 93

app/views/layouts/application.html.erb

12 <%= stylesheet_pack_tag 'application', media: 'all' %> 3 <%= javascript_pack_tag "application", "data-turbo-track": "reload", defer: true %>

試したこと・調べたこと

上記の詳細・結果

entryの設定が不正であるとされている。entryは空でないオブジェクトである必要があり、チャンク名がキーで、値は文字列または配列でなければならないというエラーとのことでsource_entry_path: packs から source_entry_path: entry に変更し再起動したのですが変わらず...

default: &default source_path: app/javascript source_entry_path: entry public_root_path: public public_output_path: packs cache_path: tmp/cache/webpacker webpack_compile_output: true # Additional paths webpack should lookup modules # ['app/assets', 'engine/foo/app/assets'] additional_paths: [] # Reload manifest.json on all requests so we reload latest compiled packs cache_manifest: false (以下略)

補足

特になし

コメントを投稿

0 コメント