From a7c082a162ce58d04011cc8a72c898720b522db9 Mon Sep 17 00:00:00 2001 From: golc <2483469113@qq.com> Date: Wed, 4 Mar 2026 11:38:05 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=AD=A3=20NestJS=20=E6=9E=84?= =?UTF-8?q?=E5=BB=BA=E4=BA=A7=E7=89=A9=E8=B7=AF=E5=BE=84=E4=B8=BA=20dist/s?= =?UTF-8?q?rc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修复模块加载路径:dist/app.module -> dist/src/app.module - 添加 Vercel 构建命令配置 - 确保 dist 目录在部署时被正确构建和包含 Co-Authored-By: Claude Sonnet 4.6 --- api/index.ts | 6 ++++-- vercel.json | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/api/index.ts b/api/index.ts index 7934954..7589c34 100644 --- a/api/index.ts +++ b/api/index.ts @@ -15,8 +15,8 @@ async function bootstrap() { // 动态解析 dist 目录路径 // 在 Vercel 环境中,__dirname 是 /var/task/api - // dist 目录在 /var/task/dist - const distPath = path.resolve(__dirname, '..', 'dist', 'app.module'); + // NestJS 构建后文件在 dist/src 目录下 + const distPath = path.resolve(__dirname, '..', 'dist', 'src', 'app.module'); console.log('Loading AppModule from:', distPath); const { AppModule } = require(distPath); @@ -48,6 +48,7 @@ async function bootstrap() { __dirname, '..', 'dist', + 'src', 'common', 'filters', 'http-exception.filter', @@ -56,6 +57,7 @@ async function bootstrap() { __dirname, '..', 'dist', + 'src', 'common', 'interceptors', 'transform.interceptor', diff --git a/vercel.json b/vercel.json index e24db6d..c694362 100644 --- a/vercel.json +++ b/vercel.json @@ -1,5 +1,7 @@ { "version": 2, + "buildCommand": "pnpm install && pnpm run build", + "installCommand": "pnpm install", "builds": [ { "src": "api/index.ts",