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

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

新規登録して質問してみよう
ただいま回答率
85.46%
Vue.js

Vue.jsは、Webアプリケーションのインターフェースを構築するためのオープンソースJavaScriptフレームワークです。

docker-compose

docker-composeとは、複数のコンテナで構成されるサービスを提供する手順を自動的し管理を簡単にするツール。composeファイルを使用しコマンド1回で設定した全サービスを作成・起動することが可能です。

Nuxt.js

Nuxt.jsは、ユニバーサルなSPAが開発可能なVue.jsベースのフレームワーク。UIの描画サポートに特化しており、SSRにおけるサーバーサイドとクライアントサイドのUIレンダリングなどさまざまな機能を持ちます。

Docker

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

Q&A

解決済

1回答

1882閲覧

【Nuxt.js】Docker-composeで立てたコンテナ内でyarn create nuxt-appを使うとページが表示されない

退会済みユーザー

退会済みユーザー

総合スコア0

Vue.js

Vue.jsは、Webアプリケーションのインターフェースを構築するためのオープンソースJavaScriptフレームワークです。

docker-compose

docker-composeとは、複数のコンテナで構成されるサービスを提供する手順を自動的し管理を簡単にするツール。composeファイルを使用しコマンド1回で設定した全サービスを作成・起動することが可能です。

Nuxt.js

Nuxt.jsは、ユニバーサルなSPAが開発可能なVue.jsベースのフレームワーク。UIの描画サポートに特化しており、SSRにおけるサーバーサイドとクライアントサイドのUIレンダリングなどさまざまな機能を持ちます。

Docker

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

0グッド

0クリップ

投稿2021/09/07 01:11

編集2021/09/07 11:23

実現したいこと

Dockerとyarn create nuxt-appを使いnuxt.jsの環境を作成しようとしたところ、yarn devまで進めたが、その後表示されるはずのテンプレートページが表示されず真っ白なページが表示されてしまうのでそれを解決したい。

前提

  • index.vueの中身を普通のHTML(<h1>hogehoge</h1>など)に書き換えると表示される
  • 参照しているコンポーネントをNuxtLogo.vueに変更するとそれっぽいものが表示される

発生している問題・エラーメッセージ

[Vue warn]: The client-side rendered virtual DOM tree is not matching server-rendered content. This is likely caused by incorrect HTML markup, for example nesting block-level elements inside <p>, or missing <tbody>. Bailing hydration and performing full client-side render. warn @ vue.runtime.esm.js?2b0e:619 vue.runtime.esm.js?2b0e:619
[Vue warn]: Unknown custom element: <Tutorial> - did you register the component correctly? For recursive components, make sure to provide the "name" option. found in ---> <Pages/index.vue> at pages/index.vue <Nuxt> <.nuxt/layouts/default.vue> at .nuxt/layouts/default.vue <Root> warn @ vue.runtime.esm.js?2b0e:619

ディレクトリ構成

hogehoge ├ src │ ├ .nuxt │ ├ components │ │ ├ NuxtLogo.vue │ │ └ Tutorial.vue │ ├ node_modules │ ├ pages │ │ └ index.vue │ ├ static │ ├ store │ ├ .editconfig │ ├ .gitignore │ ├ nuxt.config.js │ ├ package.json │ └ yarn.lock ├ docker-compose.yml └ Dockerfile

ソースコード

Dockerfile

Dockerfile

1FROM node:alpine 2 3WORKDIR /src 4 5RUN apk update

docker-compose.yml

yml

1version: '3.8' 2 3services: 4 app: 5 build: . 6 container_name: nuxt 7 ports: 8 - '3000:3000' 9 volumes: 10 - ./src:/src 11 stdin_open: true 12 tty: true 13 environment: 14 - CHOKIDAR_USEPOLLING=true

index.vue

vue

1<template> 2 <Tutorial/> 3</template> 4 5<script> 6export default {} 7</script>

Tutorial.vue

vue

1<!-- Please remove this file from your project --> 2<template> 3 <div class="relative flex items-top justify-center min-h-screen bg-gray-100 sm:items-center sm:pt-0"> 4 <link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.1.2/dist/tailwind.min.css" rel="stylesheet"> 5 <div class="max-w-4xl mx-auto sm:px-6 lg:px-8"> 6 <a class="flex justify-center pt-8 sm:pt-0" href="https://nuxtjs.org" target="_blank"> 7 <svg width="218" height="45" viewBox="0 0 159 30" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M55.5017 6.81866H60.1727L70.0719 22.9912V6.81866H74.3837V29.7345H69.7446L59.8135 13.5955V29.7345H55.5017V6.81866Z" fill="#003543" /> <path d="M93.657 29.7344H89.6389V27.1747C88.7241 28.9761 86.8628 29.9904 84.5113 29.9904C80.7869 29.9904 78.3684 27.3059 78.3684 23.4423V13.2339H82.3865V22.5976C82.3865 24.8566 83.7594 26.4276 85.8171 26.4276C88.0712 26.4276 89.6389 24.6598 89.6389 22.2377V13.2339H93.657V29.7344Z" fill="#003543" /> <path d="M107.64 29.7344L103.784 24.2342L99.9291 29.7344H95.6492L101.596 21.1242L96.1074 13.2339H100.485L103.784 17.9821L107.051 13.2339H111.461L105.94 21.1242L111.886 29.7344H107.64Z" fill="#003543" /> <path d="M120.053 8.25848V13.2339H124.627V16.6063H120.053V24.7974C120.053 25.0725 120.162 25.3363 120.356 25.531C120.55 25.7257 120.813 25.8353 121.087 25.8357H124.627V29.728H121.98C118.386 29.728 116.035 27.6323 116.035 23.9687V16.6095H112.801V13.2339H114.83C115.776 13.2339 116.327 12.6692 116.327 11.7349V8.25848H120.053Z" fill="#003543" /> <path d="M134.756 24.5446V6.81866H139.066V23.1864C139.066 27.6067 136.943 29.7345 133.349 29.7345H128.332V25.8421H133.461C133.804 25.8421 134.134 25.7054 134.377 25.4621C134.619 25.2188 134.756 24.8888 134.756 24.5446Z" fill="#003543" /> <path d="M141.649 22.0409H145.799C146.029 24.6006 147.728 26.2308 150.472 26.2308C152.923 26.2308 154.623 25.2501 154.623 23.2199C154.623 18.3085 142.331 21.7129 142.331 12.9395C142.334 9.17515 145.568 6.55945 150.215 6.55945C155.05 6.55945 158.317 9.34153 158.516 13.6306H154.388C154.193 11.6341 152.632 10.2918 150.207 10.2918C147.953 10.2918 146.548 11.3397 146.548 12.9427C146.548 18.0173 159 14.2226 159 23.1576C159 27.4131 155.504 30 150.474 30C145.279 30 141.882 26.8563 141.654 22.0441" fill="#003543" /> <path d="M24.7203 29.704H41.1008C41.6211 29.7041 42.1322 29.5669 42.5828 29.3061C43.0334 29.0454 43.4075 28.6704 43.6675 28.2188C43.9275 27.7672 44.0643 27.2549 44.0641 26.7335C44.0639 26.2121 43.9266 25.6999 43.6662 25.2485L32.6655 6.15312C32.4055 5.70162 32.0315 5.32667 31.581 5.06598C31.1305 4.8053 30.6195 4.66805 30.0994 4.66805C29.5792 4.66805 29.0682 4.8053 28.6177 5.06598C28.1672 5.32667 27.7932 5.70162 27.5332 6.15312L24.7203 11.039L19.2208 1.48485C18.9606 1.03338 18.5864 0.658493 18.1358 0.397853C17.6852 0.137213 17.1741 0 16.6538 0C16.1336 0 15.6225 0.137213 15.1719 0.397853C14.7213 0.658493 14.3471 1.03338 14.0868 1.48485L0.397874 25.2485C0.137452 25.6999 0.000226653 26.2121 2.8053e-07 26.7335C-0.000226092 27.2549 0.136554 27.7672 0.396584 28.2188C0.656614 28.6704 1.03072 29.0454 1.48129 29.3061C1.93185 29.5669 2.44298 29.7041 2.96326 29.704H13.2456C17.3195 29.704 20.3239 27.9106 22.3912 24.4118L27.4102 15.7008L30.0986 11.039L38.1667 25.0422H27.4102L24.7203 29.704ZM13.0779 25.0374L5.9022 25.0358L16.6586 6.36589L22.0257 15.7008L18.4322 21.9401C17.0593 24.2103 15.4996 25.0374 13.0779 25.0374Z" fill="#00DC82" /></svg> 8 </a> 9 <div class="mt-8 bg-white overflow-hidden shadow sm:rounded-lg p-6"> 10 <h2 class="text-2xl leading-7 font-semibold"> 11 Welcome to your Nuxt Application 12 </h2> 13 <p class="mt-3 text-gray-600"> 14 We recommend you take a look at the <a href="https://nuxtjs.org" target="_blank" class="text-green-500 hover:underline">Nuxt documentation</a>, whether you are new or have previous experience with the framework.<br> 15 </p> 16 <p class="mt-4 pt-4 text-gray-800 border-t border-dashed"> 17 To get started, remove <code class="bg-gray-100 text-sm p-1 rounded border">components/Tutorial.vue</code> and start coding in <code class="bg-gray-100 text-sm p-1 rounded border">pages/index.vue</code>. Have fun! 18 </p> 19 </div> 20 <div class="flex justify-center pt-4 space-x-2"> 21 <a href="https://github.com/nuxt/nuxt.js" target="_blank"><svg 22 class="w-6 h-6 text-gray-600 hover:text-gray-800" 23 xmlns="http://www.w3.org/2000/svg" 24 xmlns:xlink="http://www.w3.org/1999/xlink" 25 aria-hidden="true" 26 role="img" 27 width="32" 28 height="32" 29 preserveAspectRatio="xMidYMid meet" 30 viewBox="0 0 24 24" 31 ><path d="M12 2.247a10 10 0 0 0-3.162 19.487c.5.088.687-.212.687-.475c0-.237-.012-1.025-.012-1.862c-2.513.462-3.163-.613-3.363-1.175a3.636 3.636 0 0 0-1.025-1.413c-.35-.187-.85-.65-.013-.662a2.001 2.001 0 0 1 1.538 1.025a2.137 2.137 0 0 0 2.912.825a2.104 2.104 0 0 1 .638-1.338c-2.225-.25-4.55-1.112-4.55-4.937a3.892 3.892 0 0 1 1.025-2.688a3.594 3.594 0 0 1 .1-2.65s.837-.262 2.75 1.025a9.427 9.427 0 0 1 5 0c1.912-1.3 2.75-1.025 2.75-1.025a3.593 3.593 0 0 1 .1 2.65a3.869 3.869 0 0 1 1.025 2.688c0 3.837-2.338 4.687-4.563 4.937a2.368 2.368 0 0 1 .675 1.85c0 1.338-.012 2.413-.012 2.75c0 .263.187.575.687.475A10.005 10.005 0 0 0 12 2.247z" fill="currentColor" /></svg></a> 32 <a href="https://twitter.com/nuxt_js" target="_blank"><svg 33 class="w-6 h-6 text-gray-600 hover:text-gray-800" 34 xmlns="http://www.w3.org/2000/svg" 35 xmlns:xlink="http://www.w3.org/1999/xlink" 36 aria-hidden="true" 37 role="img" 38 width="32" 39 height="32" 40 preserveAspectRatio="xMidYMid meet" 41 viewBox="0 0 24 24" 42 ><path d="M22.46 6c-.77.35-1.6.58-2.46.69c.88-.53 1.56-1.37 1.88-2.38c-.83.5-1.75.85-2.72 1.05C18.37 4.5 17.26 4 16 4c-2.35 0-4.27 1.92-4.27 4.29c0 .34.04.67.11.98C8.28 9.09 5.11 7.38 3 4.79c-.37.63-.58 1.37-.58 2.15c0 1.49.75 2.81 1.91 3.56c-.71 0-1.37-.2-1.95-.5v.03c0 2.08 1.48 3.82 3.44 4.21a4.22 4.22 0 0 1-1.93.07a4.28 4.28 0 0 0 4 2.98a8.521 8.521 0 0 1-5.33 1.84c-.34 0-.68-.02-1.02-.06C3.44 20.29 5.7 21 8.12 21C16 21 20.33 14.46 20.33 8.79c0-.19 0-.37-.01-.56c.84-.6 1.56-1.36 2.14-2.23z" fill="currentColor" /></svg></a> 43 </div> 44 </div> 45 </div> 46</template>

create-nuxt-appの設定

? Project name: src ? Programming language: JavaScript ? Package manager: Yarn ? UI framework: None ? Nuxt.js modules: (Press <space> to select, <a> to toggle all, <i> to invert selection) ? Linting tools: (Press <space> to select, <a> to toggle all, <i> to invert selection) ? Testing framework: None ? Rendering mode: Universal (SSR / SSG) ? Deployment target: Server (Node.js hosting) ? Development tools: (Press <space> to select, <a> to toggle all, <i> to invert selection) ? What is your GitHub username? szne ? Version control system: None

試したこと

  • Nuxt.comfig.jsに以下の記述を追加

js

1module.exports = { 2 server: { 3 port: 3000, 4 host: '0.0.0.0' 5 }, 6}
  • create nuxt-appのディレクトリを変更(例: .から./hogeに)
  • マウントするボリュームの変更

補足情報(FW/ツールのバージョンなど)

> systeminfo OS Name: Microsoft Windows 10 Home OS Version: 10.0.19043 N/A Build 19043 > docker -v Docker version 20.10.5, build 55c4c88 > docker-compose -v docker-compose version 1.29.0, build 07737305 > docker run --rm node:alpine sh -c "cat /etc/*-release" 3.13.6 NAME="Alpine Linux" ID=alpine VERSION_ID=3.13.6 PRETTY_NAME="Alpine Linux v3.13" HOME_URL="https://alpinelinux.org/" BUG_REPORT_URL="https://bugs.alpinelinux.org/" /src # yarn -v 1.22.5 Nuxt @ v2.15.8

追記

2021/9/7 15:30 こちらの記事の通りに立ち上げたら成功しました

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

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

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

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

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

guest

回答1

0

ベストアンサー

Dockerfile、docker-compose.ymlを下記のように修正したら解決しました。

Dockerfile

1FROM node:alpine 2 3RUN apk update && \ 4 yarn global add create-nuxt-app 5 6ENV HOST 0.0.0.0 7EXPOSE 3000

yml

1version: '3.8' 2 3services: 4 app: 5 build: . 6 ports: 7 - "3000:3000" 8 working_dir: "/src" 9 volumes: 10 - "./src:/src" 11 - node_modules_volume:/src/node_modules 12 tty: true 13 environment: 14 - CHOKIDAR_USEPOLLING=true 15volumes: 16 node_modules_volume:

投稿2021/09/07 08:53

退会済みユーザー

退会済みユーザー

総合スコア0

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

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

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.46%

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

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

質問する

関連した質問