質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.47%
Yarn

Yarnは、Facebook/Exponent/Google/Tildeが開発したJavaScriptのパッケージマネージャ。npmよりもインストールが速く、厳密にモジュールのバージョンを固定できるなど、npmの問題を解決。npmと互換性があり、同じpackage.jsonを使用できます。

Ruby on Rails 6

Ruby on Rails 6は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Docker

Dockerは、Docker社が開発したオープンソースのコンテナー管理ソフトウェアの1つです

Q&A

0回答

835閲覧

webpackを正常にインストールできたはずなのに、Webpacker::Manifest::MissingEntryError in StaticPagesエラー

退会済みユーザー

退会済みユーザー

総合スコア0

Yarn

Yarnは、Facebook/Exponent/Google/Tildeが開発したJavaScriptのパッケージマネージャ。npmよりもインストールが速く、厳密にモジュールのバージョンを固定できるなど、npmの問題を解決。npmと互換性があり、同じpackage.jsonを使用できます。

Ruby on Rails 6

Ruby on Rails 6は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Docker

Dockerは、Docker社が開発したオープンソースのコンテナー管理ソフトウェアの1つです

0グッド

0クリップ

投稿2021/01/17 07:15

編集2021/01/17 07:17

dockerを用い、rails6でアプリケーションを作っています。
yarn、とnodejsは、Dockerfileにて既にインストールしました。
localhostにサーバーを立ち上げようとしたら、rails webpacker:installしてとエラーが出たので、bundle exec rails webpacker:installをし、webpackをインストールしました。

... ... ... ├─ y18n@4.0.1 ├─ yargs-parser@13.1.2 └─ yargs@13.3.2 Done in 23.07s. Webpacker successfully installed ???? ???? root@6c5564a989c0:/container# bundle exec rails g controller StaticPages home help create app/controllers/static_pages_controller.rb route get 'static_pages/home' get 'static_pages/help' invoke erb create app/views/static_pages create app/views/static_pages/home.html.erb create app/views/static_pages/help.html.erb invoke test_unit create test/controllers/static_pages_controller_test.rb invoke helper create app/helpers/static_pages_helper.rb invoke test_unit invoke assets invoke scss create app/assets/stylesheets/static_pages.scss

結果、localhost3000上に、You're on railsのページが表示される様になりました。

イメージ説明

問題

ここからが問題です。
You're on railsのページは表示されますが、上記で作ったroute static_pages/homeにアクセスすると、以下のエラーが出ます。

イメージ説明
以下、詳細です。

root@6c5564a989c0:/container# rails s -b 0.0.0.0 => Booting Puma => Rails 6.0.3 application starting in development => Run `rails server --help` for more startup options Puma starting in single mode... * Version 4.3.6 (ruby 2.6.3-p62), codename: Mysterious Traveller * Min threads: 5, max threads: 5 * Environment: development * Listening on tcp://0.0.0.0:3000 Use Ctrl-C to stop Started GET "/" for 172.23.0.1 at 2021-01-17 06:57:23 +0000 Cannot render console from 172.23.0.1! Allowed networks: 127.0.0.0/127.255.255.255, ::1 Processing by Rails::WelcomeController#index as HTML Rendering /usr/local/bundle/gems/railties-6.0.3/lib/rails/templates/rails/welcome/index.html.erb Rendered /usr/local/bundle/gems/railties-6.0.3/lib/rails/templates/rails/welcome/index.html.erb (Duration: 5.2ms | Allocations: 315) Completed 200 OK in 17ms (Views: 10.1ms | ActiveRecord: 0.0ms | Allocations: 1702) Started GET "/static_pages/home" for 172.23.0.1 at 2021-01-17 07:00:50 +0000 Cannot render console from 172.23.0.1! Allowed networks: 127.0.0.0/127.255.255.255, ::1 Processing by StaticPagesController#home as HTML Rendering static_pages/home.html.erb within layouts/application Rendered static_pages/home.html.erb within layouts/application (Duration: 1.2ms | Allocations: 91) [Webpacker] Compiling… Started GET "/static_pages/home" for 172.23.0.1 at 2021-01-17 07:00:54 +0000 Cannot render console from 172.23.0.1! Allowed networks: 127.0.0.0/127.255.255.255, ::1 Processing by StaticPagesController#home as HTML Rendering static_pages/home.html.erb within layouts/application Rendered static_pages/home.html.erb within layouts/application (Duration: 0.1ms | Allocations: 5) [Webpacker] Compiling… [Webpacker] Compilation failed: [webpack-cli] Failed to load '/container/config/webpack/development.js' [webpack-cli] TypeError: Cannot read property 'toWebpackConfig' of undefined at Object.<anonymous> (/container/config/webpack/development.js:5:30) at Module._compile (/container/node_modules/v8-compile-cache/v8-compile-cache.js:192:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10) at Module.load (internal/modules/cjs/loader.js:653:32) at tryModuleLoad (internal/modules/cjs/loader.js:593:12) at Function.Module._load (internal/modules/cjs/loader.js:585:3) at Module.require (internal/modules/cjs/loader.js:692:17) at require (/container/node_modules/v8-compile-cache/v8-compile-cache.js:159:20) at loadConfig (/container/node_modules/webpack-cli/lib/webpack-cli.js:753:31) at Promise.all.options.config.map (/container/node_modules/webpack-cli/lib/webpack-cli.js:823:48) Completed 500 Internal Server Error in 4326ms (ActiveRecord: 0.0ms | Allocations: 1011027) ActionView::Template::Error (Webpacker can't find application in /container/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: { } ): 6: <%= csp_meta_tag %> 7: 8: <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> 9: <%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %> 10: </head> 11: 12: <body> app/views/layouts/application.html.erb:9 [Webpacker] Compilation failed: [webpack-cli] Failed to load '/container/config/webpack/development.js' [webpack-cli] TypeError: Cannot read property 'toWebpackConfig' of undefined at Object.<anonymous> (/container/config/webpack/development.js:5:30) at Module._compile (/container/node_modules/v8-compile-cache/v8-compile-cache.js:192:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10) at Module.load (internal/modules/cjs/loader.js:653:32) at tryModuleLoad (internal/modules/cjs/loader.js:593:12) at Function.Module._load (internal/modules/cjs/loader.js:585:3) at Module.require (internal/modules/cjs/loader.js:692:17) at require (/container/node_modules/v8-compile-cache/v8-compile-cache.js:159:20) at loadConfig (/container/node_modules/webpack-cli/lib/webpack-cli.js:753:31) at Promise.all.options.config.map (/container/node_modules/webpack-cli/lib/webpack-cli.js:823:48) Completed 500 Internal Server Error in 3374ms (ActiveRecord: 0.0ms | Allocations: 320905) ActionView::Template::Error (Webpacker can't find application in /container/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: { } ): 6: <%= csp_meta_tag %> 7: 8: <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> 9: <%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %> 10: </head> 11: 12: <body> app/views/layouts/application.html.erb:9

yarnは最新状態です。
また、webpack用のサーバーを動かそうとしましたが、こちらもうまく機能しません。

root@6c5564a989c0:/container# bundle exec rails yarn:install yarn install v1.22.5 [1/4] Resolving packages... success Already up-to-date. Done in 0.45s. root@6c5564a989c0:/container# bin/webpack-dev-server internal/modules/cjs/loader.js:638 throw err; ^ Error: Cannot find module 'webpack-cli/bin/config-yargs' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15) at Function.Module._load (internal/modules/cjs/loader.js:562:25) at Module.require (internal/modules/cjs/loader.js:692:17) at require (internal/modules/cjs/helpers.js:25:18) at Object.<anonymous> (/container/node_modules/webpack-dev-server/bin/webpack-dev-server.js:65:1) at Module._compile (internal/modules/cjs/loader.js:778:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10) at Module.load (internal/modules/cjs/loader.js:653:32) at tryModuleLoad (internal/modules/cjs/loader.js:593:12) at Function.Module._load (internal/modules/cjs/loader.js:585:3)

とりあえず、localhost3000/static_pages/homeでアクセスするとこまでしたいです。わかる方いたらよろしくお願いします。

環境

FROM ruby:2.6.3 RUN apt-get update && apt-get install -y \ build-essential \ libpq-dev \ nodejs \ postgresql # yarnパッケージ管理ツールをインストール RUN apt-get update && apt-get install -y curl apt-transport-https wget && \ curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \ echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \ apt-get update && apt-get install -y yarn # Node.jsをインストール RUN curl -sL https://deb.nodesource.com/setup_7.x | bash - && \ apt-get install nodejs WORKDIR /container COPY Gemfile Gemfile.lock /container/ RUN bundle install

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.47%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問