vercel-deploy

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Vercel Deployment Skill

Vercel 部署技能

Goal: Seamlessly deploy any frontend/full-stack application to Vercel global edge network.
目标:将任意前端/全栈应用无缝部署到Vercel全球边缘网络。

1. Prerequisites

1. 前提条件

  • CLI:
    vercel
    (Install via
    npm i -g vercel
    )
  • Auth: User must be logged in (
    vercel login
    ) or provide
    VERCEL_TOKEN
    .
  • CLI
    vercel
    (通过
    npm i -g vercel
    安装)
  • 身份验证:用户必须已登录(
    vercel login
    )或提供
    VERCEL_TOKEN

2. Deployment Workflow

2. 部署流程

  1. Detection:
    • Scanner checks
      package.json
      for frameworks (Next.js, Vite, Remix, Astro).
    • Identifies build command (
      npm run build
      ) and output directory (
      dist
      or
      .next
      ).
  2. Configuration:
    • Generates
      vercel.json
      if custom headers/rewrites are needed.
    • Sets project settings (Root Directory, Framework Preset).
  3. Execution:
    • Preview:
      vercel --no-prod
      (For testing feature branches).
    • Production:
      vercel --prod
      (For live release).
  4. Verification:
    • Checks deployment status via
      vercel inspect <url>
      .
    • Returns the Claimable URL for the user.
  1. 检测:
    • 扫描器检查
      package.json
      中的框架(Next.js、Vite、Remix、Astro)。
    • 识别构建命令(
      npm run build
      )和输出目录(
      dist
      .next
      )。
  2. 配置:
    • 如果需要自定义头信息/重写规则,生成
      vercel.json
    • 设置项目参数(根目录、框架预设)。
  3. 执行:
    • 预览部署
      vercel --no-prod
      (用于测试功能分支)。
    • 生产部署
      vercel --prod
      (用于正式发布)。
  4. 验证:
    • 通过
      vercel inspect <url>
      检查部署状态。
    • 向用户返回可认领的URL。

3. Environment Variables

3. 环境变量

  • Auto-Sync: Pulls
    .env
    from Vercel Project Settings (
    vercel env pull
    ).
  • Push: Pushes local
    .env
    to Vercel (Interactive confirmation required).
  • 自动同步:从Vercel项目设置中拉取
    .env
    文件(
    vercel env pull
    )。
  • 推送:将本地
    .env
    文件推送到Vercel(需要交互式确认)。

4. Troubleshooting common errors

4. 常见错误排查

  • Build Fail: Usually due to strict type checking or linting in CI. Suggest
    ignoreBuildErrors: true
    ONLY for hotfixes.
  • Missing Secrets: Check if
    VERCEL_TOKEN
    is active in CI/CD environment.

Command Reference:
  • vercel link
    : Link local folder to remote project.
  • vercel deploy
    : Deploy preview.
  • vercel deploy --prod
    : Deploy production.
  • 构建失败:通常是由于CI中的严格类型检查或代码审查导致。仅建议在热修复时设置
    ignoreBuildErrors: true
  • 密钥缺失:检查CI/CD环境中
    VERCEL_TOKEN
    是否有效。

命令参考:
  • vercel link
    : 将本地文件夹关联到远程项目。
  • vercel deploy
    : 部署预览版本。
  • vercel deploy --prod
    : 部署生产版本。