我使用aws amplify来部署nuxt3框架。 构建没问题,没有显示任何错误。以下是日志
71f66f4e.mjs.map (2.91 kB) (879 B gzip)
├─ .output/server/chunks/app/_nuxt/ContentRenderer-71f66f4e.mjs (4.14 kB) (1.46 kB gzip)
├─ .output/server/chunks/app/_nuxt/ContentQuery-ab673a1a.mjs.map (10.4 kB) (2.23 kB gzip)
├─ .output/server/chunks/app/_nuxt/ContentQuery-ab673a1a.mjs (10.4 kB) (2.95 kB gzip)
├─ .output/server/chunks/app/_nuxt/ContentNavigation-d9b677b2.mjs.map (58 kB) (4.3 kB gzip)
├─ .output/server/chunks/app/_nuxt/ContentNavigation-d9b677b2.mjs (158 kB) (26.3 kB gzip)
├─ .output/server/chunks/app/_nuxt/ContentList-0bb27936.mjs.map (2.35 kB) (755 B gzip)
├─ .output/server/chunks/app/_nuxt/ContentList-0bb27936.mjs (3.73 kB) (1.34 kB gzip)
├─ .output/server/chunks/app/_nuxt/ContentDoc-6f479eaf.mjs.map (3.3 kB) (922 B gzip)
├─ .output/server/chunks/app/_nuxt/ContentDoc-6f479eaf.mjs (5.22 kB) (1.72 kB gzip)
├─ .output/server/chunks/app/_nuxt/client-only-6cbaeabd.mjs.map (2.92 kB) (929 B gzip)
├─ .output/server/chunks/app/_nuxt/client-only-6cbaeabd.mjs (2.46 kB) (918 B gzip)
├─ .output/server/chunks/app/_nuxt/client-db-68f7aeab.mjs.map (14.2 kB) (3.32 kB gzip)
├─ .output/server/chunks/app/_nuxt/client-db-68f7aeab.mjs (14.2 kB) (4.21 kB gzip)
├─ .output/server/chunks/app/_nuxt/Button-f4409d41.mjs.map (3.22 kB) (963 B gzip)
├─ .output/server/chunks/app/_nuxt/Button-f4409d41.mjs (4.96 kB) (1.67 kB gzip)
├─ .output/server/chunks/app/_nuxt/auth-be280cc0.mjs.map (1.16 kB) (461 B gzip)
├─ .output/server/chunks/app/_nuxt/auth-be280cc0.mjs (1.08 kB) (504 B gzip)
├─ .output/server/chunks/app/_nuxt/404-6d7523e2.mjs.map (1.71 kB) (671 B gzip)
├─ .output/server/chunks/app/_nuxt/404-6d7523e2.mjs (3.15 kB) (1.23 kB gzip)
├─ .output/server/chunks/app/_nuxt/_plugin-vue_export-helper-cc2b3d55.mjs.map (484 B) (295 B gzip)
└─ .output/server/chunks/app/_nuxt/_plugin-vue_export-helper-cc2b3d55.mjs (254 B) (200 B gzip)
Σ Total size: 14.7 MB (2.94 MB gzip)
2023-04-15T10:56:55.717Z [INFO]: [success] [nitro] You can preview this build using `node .output/server/index.mjs`
2023-04-15T10:56:55.748Z [INFO]: Done in 33.88s.
2023-04-15T10:56:55.752Z [INFO]: # Completed phase: build
2023-04-15T10:56:55.754Z [INFO]: ## Build completed successfully
2023-04-15T10:56:55.755Z [INFO]: # Starting caching...
2023-04-15T10:56:55.765Z [INFO]: # Creating cache artifact...
2023-04-15T10:57:05.286Z [INFO]: # Created cache artifact
2023-04-15T10:57:05.439Z [INFO]: # Uploading cache artifact...
2023-04-15T10:57:09.461Z [INFO]: # Uploaded cache artifact
2023-04-15T10:57:09.560Z [INFO]: # Caching completed
2023-04-15T10:57:09.567Z [INFO]: # No custom headers found.
2023-04-15T10:57:09.600Z [WARNING]: !! No index.html detected in deploy folder: /codebuild/output/src412744304/src/main-landing-page/.output/server/
2023-04-15T10:57:09.601Z [INFO]: # Starting build artifact upload process...
2023-04-15T10:57:10.202Z [INFO]: # Uploading build artifact '__artifacts.zip'...
2023-04-15T10:57:10.236Z [INFO]: # Uploading build artifact '__artifactsHash.zip'...
2023-04-15T10:57:10.368Z [INFO]: # Build artifact upload completed
2023-04-15T10:57:10.368Z [INFO]: # Starting environment caching...
2023-04-15T10:57:10.368Z [INFO]: # Uploading environment cache artifact...
2023-04-15T10:57:10.449Z [INFO]: # Uploaded environment cache artifact
2023-04-15T10:57:10.450Z [INFO]: # Environment caching completed
Terminating logging...
这是我的 AWS Amplify 构建设置
version: 1
frontend:
phases:
preBuild:
commands:
- yarn install
build:
commands:
- yarn build
artifacts:
baseDirectory: .output/server/
files:
- '**/*'
cache:
paths:
- node_modules/**/*
我根据本文档使用基目录.output/server 因为当我使用 dist 或 /dist 时,它显示错误,找不到文件夹 https://nuxt.com/docs/getting-started/deployment#supported-hosting-providers
构建成功,但是当我尝试访问该链接时,它只显示http错误404
构建规范使用节点版本 16
看起来您的输出目录正确,但 Nuxt 3
npm run generate
不输出 index.html,因此请仔细检查您的 Amplify 项目重写和重定向,以便 200.html 是默认网页,404.html 是你的404
您需要将 AWS 构建配置文件切换为类似这样的文件。
也可与 NPM 配合使用。
版本:1 前端: 阶段: 预构建: 命令: - 纱线安装 建造: 命令: - 纱线生成 文物: 基目录:.output/public 文件: - '/*' 缓存: 路径: - 节点模块//*