$ npm run start
> app@1.2.3 start /home/app/ui/web
> nuxt start
FATAL No build files found in /home/app/ui/web/.nuxt/dist/server.
Use either `nuxt build` or `builder.build()` or start nuxt in development mode.
在多阶段构建的 Docker 镜像中启动 Nuxt.js 应用程序时发生错误:
npm ci && npm run build
在构建阶段图像中.nuxt
以及 package.json
和 node_modules
复制到运行阶段图像中关于环境的一些细节。
Nuxt.js 应用模式是'spa'。丢失的文件确实存在于最终图像中,没有使用任何卷/安装。构建阶段和运行阶段镜像之间的操作系统用户名不同,但是(希望如此)情况不应如此。
Nuxt.js 2.12.2,Node.js 14.16.0。
最佳答案
nuxt.config.js
丢失了。
在我将它复制到运行阶段镜像中,并从 localhost
切换到 server.host
的 0.0.0.0
之后nuxt.config.js
中的属性,容器运行正常:
> app@1.2.3 start /home/app/ui/web
> nuxt start
ℹ Listening on: http://172.17.0.2:3000/
因此,在服务器部署模式下运行产品构建所需的项目(表面上)如下:
/.nuxt
/node_modules
nuxt.config.js
package.json
关于最终工件中应包含的内容,文档在某种程度上含糊不清: https://nuxtjs.org/docs/2.x/get-started/commands/#server-deployment
激发故障排除的另一个 SO 问题: Nuxt deployment error: server resources are not available
将 Nuxt 更新到 2.15.3,从临时 npm
构建切换到通过 yarn
的可重现构建。
构建阶段变成了 yarn install --frozen-lockfile && yarn build
。此外,将 node_modules
从构建阶段复制到运行阶段会将开发依赖项带入 prod,Nuxt 应用程序的 b/c prod 构建需要开发依赖项。因此,在运行阶段,切换到 yarn install --frozen-lockfile --production=true
而不是从之前的构建阶段复制 node_modules
。
从构建阶段复制的用于在服务器部署模式 (https://nuxtjs.org/docs/2.x/features/deployment-targets/#server-hosting) 中运行产品 Nuxt 应用程序的所需项目如下:
/.nuxt
nuxt.config.js
package.json
yarn.lock
https://stackoverflow.com/questions/66987028/
相关文章:
azure - Get-AzRoleAssignment 在 Azure Runbook 中引发 M
python - 我无法使用 matplotlib 在 colab 上绘图
telegram-bot - 用于从机器人类发送的消息的 CallbackQueryHandler
javascript - Css 过渡不适用于 React 中的条件渲染
reactjs - 如何在嵌入式 React App 中的页面之间路由?
python - datetime.combine with timezone 不同于 dateti