简体   繁体   English

Nuxt 不创建 dist 目录

[英]Nuxt not creating dist directory

I use docker-compose to build and run an SSR Nuxt.JS application.我使用 docker docker-compose来构建和运行一个 SSR Nuxt.JS 应用程序。 Web server is nginx .网络服务器是nginx

I cannot use nginx reverse proxy to run this application, because directory dist is not created in /app/ .我不能使用 nginx 反向代理来运行这个应用程序,因为目录dist没有在/app/创建。 This is my Dockerfile :这是我的Dockerfile

FROM node:14.17.0-alpine
WORKDIR /app
COPY . /app
RUN apk add python make g++
RUN yarn install
RUN yarn build
ENV HOST 0.0.0.0
ENV PORT 3000
ENV NODE_ENV production
EXPOSE 3000
CMD [ "yarn", "start" ]

It does not work.这是行不通的。 But If I run this command in my docker host path /home/path/project-1/ (the path Nuxt.JS files exist):但是如果我在我的 docker 主机路径/home/path/project-1/ (路径 Nuxt.JS 文件存在)中运行这个命令:

yarn start

I can temporarily see the application via:我可以通过以下方式暂时查看应用程序:

http://ip:3000

I searched and tried some solutions, but none of them worked (unfortunately).我搜索并尝试了一些解决方案,但没有一个奏效(不幸的是)。

This is the log when I run yarn start in my terminal:这是我在终端中运行yarn start时的日志:

yarn run v1.22.11
$ nuxt start
ℹ [HPM] Proxy created: /api/  -> https://api.site.com/api
ℹ [HPM] Proxy rewrite rule created: "^/api/" ~> ""

   ╭───────────────────────────────────────────╮
   │                                           │
   │   Nuxt.js @ v2.14.3                       │
   │                                           │
   │   ▸ Environment: production               │
   │   ▸ Rendering:   server-side              │
   │   ▸ Target:      server                   │
   │                                           │
   │   Memory usage: 32.7 MB (RSS: 105 MB)     │
   │                                           │
   │   Listening: http://ip:3000/   │
   │                                           │
   ╰───────────────────────────────────────────╯

What is wrong for running?跑步有什么不好?

The reason I cannot proxy pass it to nginx is that there's no document root.我不能代理将它传递给 nginx 的原因是没有文档根。 If I use # at the beginning of root directive, I use this error in nginx :如果我在root指令的开头使用# ,我会在nginx使用这个错误:

2021/10/14 12:02:29 [error] 25#25: *180 rewrite or internal redirection cycle while internally redirecting to "/index.html", client: my_ip, server: app.site.com, request: "GET / HTTP/1.1", host: "app.site.com"
2021/10/14 12:02:29 [error] 25#25: *181 rewrite or internal redirection cycle while internally redirecting to "/index.html", client: my_ip, server: app.site.com, request: "GET /favicon.ico HTTP/1.1", host: "app.site.com", referrer: "https://app.

Update 1更新 1

As said kissu, this is the related block in nuxt.config.js :至于说kissu,这是在相关区块nuxt.config.js

  target: 'server',
  server: {
    port: 3000, // default: 3000
    host: '0.0.0.0', // default: localhost
  },

使用yarn build和定位/app/.nuxt修复了这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM