From 7185009c28869356cc461950b21cd0345d1b245b Mon Sep 17 00:00:00 2001 From: golc <2483469113@qq.com> Date: Wed, 4 Mar 2026 09:54:02 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AE=8C=E6=95=B4=E4=BF=AE=E5=A4=8D=20V?= =?UTF-8?q?ercel=20=E9=83=A8=E7=BD=B2=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关键修复: - 设置 Node.js 版本为 18.x(Vercel 要求) - 排除 api/ 目录不被 TypeScript 编译 - 简化 vercel.json,让 Vercel 自动处理构建 - api/index.ts 作为独立 serverless 函数运行 技术说明: - Vercel 的 api/ 目录是特殊目录,自动识别为 serverless 函数 - api/index.ts 会被映射到 /api 路由 - src/ 目录正常编译到 dist/,供 api/index.ts 导入使用 Co-Authored-By: Claude Sonnet 4.6 --- package.json | 2 +- tsconfig.json | 3 ++- vercel.json | 8 +------- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 6b3fa03..a5870ca 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "private": true, "license": "UNLICENSED", "engines": { - "node": "20.x" + "node": "18.x" }, "scripts": { "build": "npx nest build", diff --git a/tsconfig.json b/tsconfig.json index 95f5641..bf23ec1 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -17,5 +17,6 @@ "strictBindCallApply": false, "forceConsistentCasingInFileNames": false, "noFallthroughCasesInSwitch": false - } + }, + "exclude": ["node_modules", "dist", "api"] } diff --git a/vercel.json b/vercel.json index 81097d4..85deee8 100644 --- a/vercel.json +++ b/vercel.json @@ -1,9 +1,3 @@ { - "version": 2, - "buildCommand": "pnpm run build", - "functions": { - "api/*.ts": { - "runtime": "@vercel/node@2.15.10" - } - } + "version": 2 }