buildCommand Ignored in pnpm Monorepo with Turborepo

TL;DR

**Problem**: Vercel completely ignores custom `buildCommand` in `vercel.json` for pnpm monorepo deployment, causing TypeScript compilation to fail with TS2307 “Cannot find module” errors for workspace dependencies.

**Evidence**: Debug echo statements in buildCommand don’t appear in build logs, proving Vercel runs default build process instead of our custom Turborepo orchestration.

**Impact**: Manual deployments work (pre-built deps), CI deployments fail (needs to build workspace deps first).

**Need**: Community help to understand what we’re missing or if this is a known Vercel limitation.

-–

1. Problem Description

We have a pnpm monorepo using Turborepo with a Hono-based service (`heimdall`) that deploys to Vercel Edge Runtime. The service has workspace dependencies (`@workspace/sdk`, `@workspace/helpers`, etc.) that must be built before the main service.

Vercel Project Configuration

- **Root Directory**: `apps/heimdall`

- **Framework Preset**: Hono

- **Include files outside the root directory in Build Step**: :white_check_mark: Enabled

- **Node Version**: 22.x

File Structure

├── apps/

│   └── heimdall/

│       ├── package.json

│       ├── vercel.json      # ← Custom buildCommand ignored

│       ├── tsconfig.json

│       └── src/

│           └── index.ts

├── packages/

│   ├── sdk/                 # ← Workspace dependency

│   ├── helpers/             # ← Workspace dependency

│   └── transactional/       # ← Workspace dependency

├── turbo.json               # ← Defines build dependency graph

└── pnpm-workspace.yaml

Configuration Files

**apps/heimdall/package.json**

{

“name”: “heimdall”,

“type”: “module”,

“scripts”: {

“build”: “tsc && vc build”

},

“dependencies”: {

“@workspaceworkspaceworkspaceworkspace/sdk”: “workspace:*”,

“hono”: “^4.8.5”

}

}

**apps/heimdall/vercel.json** (Being Ignored!)

{

“$schema”: “https://openapi.vercel.sh/vercel.json”,

“framework”: “hono”,

“buildCommand”: “echo \“build command used\” && cd ../../ && turbo build --filter=heimdall…”,

“installCommand”: “echo \“install command used\” && cd ../../ && pnpm install”

}

**apps/heimdall/tsconfig.json**

{

“compilerOptions”: {

“target”: “ESNext”,

“module”: “NodeNext”,

“strict”: true,

“skipLibCheck”: true,

“jsx”: “react-jsx”,

“jsxImportSource”: “hono/jsx”

},

“include”: [“src/**/*”]

}

**turbo.json** (Dependency Graph)

```json

{

“tasks”: {

“heimdall#build”: {

“depends@workspworkspacen”: [

“@worksp@wo@wkspacece/sdk#build”,

“@w@workspacer@workspacespace/helpers#build”,

“@workspace/transactional#build”

  \],

      “outputs”: [“dist/**”, “.vercel/output/**”]

     }

   }

}

```

2. What We’ve Tried

Testing Method

We use a simple `/api/v1/ping` endpoint that returns `{“message”:“pong”}` to verify deployments:

curl -H “x-vercel-protection-bypass: bypass” "https://<deploy_url>.vercel.app/api/v1/ping"

Attempted Solutions & Results

2.1 Standard vercel.json buildCommand

**Tried**: Basic buildCommand configuration

{

“buildCommand”: “turbo build --filter=heimdall…”

}

**Result**: :cross_mark: Completely ignored - no execution in build logs

2.2 Navigation to Monorepo Root

**Tried**: Adding `cd ../..` based on community patterns

{

“buildCommand”: “cd ../../ && turbo build --filter=heimdall…”

}

**Result**: :cross_mark: Still ignored - command never executes

2.3 Debug Echo Statements

**Tried**: Adding echo statements to verify execution

{

“buildCommand”: “echo \“build command used\” && cd ../../ && turbo build --filter=heimdall…”,

“installCommand”: “echo \“install command used\” && cd ../../ && pnpm install”

}

**Result**: :cross_mark: **NO echo statements appear in build logs** - definitive proof commands are ignored

2.4 Framework Override

**Tried**: Explicit framework declaration to prevent auto-detection interference

{

“framework”: “hono”,

“buildCommand”: “…”

}

**Result**: :cross_mark: No change - still ignored

2.5 Schema Declaration

**Tried**: Adding schema for proper validation

{
“$schema”: “https://openapi.vercel.sh/vercel.json”,

“buildCommand”: “…”
}

**Result**: :cross_mark: No change - still ignored

Build Log Evidence

2025-08-11T02:11:39.823Z  Running “vercel build”

2025-08-11T02:11:40.297Z  Vercel CLI 44.7.3

2025-08-11T02:11:40.475Z  > Detected Turbo. Adjusting default settings…

[… standard pnpm install process …]

2025-08-11T02:12:07.048Z  Using TypeScript 5.8.3 (local user-provided)

2025-08-11T02:12:08.889Z  Error: src/handlers/auth/magic-link-handlers.ts(1,32):
error TS2307: Cannot find module '@workspace/sdk/v1/auth/helpers/generate-otp-url'

**Key Observations**:

- :cross_mark: NO echo statements from our buildCommand appear

- :cross_mark: Vercel runs default build process: `“vercel build”`

- :cross_mark: TypeScript compilation fails on workspace imports

- :white_check_mark: D@workspacep@workspacendencies installed correctly: `+ @workspace/sdk 0.0.0 ← ../../packages/sdk`

3. What We Haven’t Tried / Ruled Out

:white_check_mark: Confirmed Working

- **Local builds**: `pnpm turbo build --filter=heimdall…` works perfectly

- **Manual deployments**: `vercel deploy` from local machine works (uses pre-built deps)

- **Endpoint functionality**: `/api/v1/ping` returns proper JSON when deps are built

:cross_mark: Ruled Out

- **File location**: vercel.json is correctly placed in `apps/heimdall/`

- **JSON syntax**: Schema validation passes, no syntax errors

- **Turborepo configuration**: Dependencies build in correct order locally

- **TypeScript config**: NodeNext module resolution works with explicit .js extensions

:thinking: Haven’t Tried Yet

1. **ENABLE_VC_BUILD=1 environment variable**: Some posts mention this flag

2. **Removing Hono framework preset**: Let Vercel auto-detect without framework hints

3. **Using `builds` property**: Though deprecated, might force custom command execution

4. **Root-level package.json scripts**: Some suggest adding scripts at repo root

5. **Custom install command without buildCommand**: Test if installCommand alone works

:clipboard: Community Patterns We’ve Researched

Based on GitHub issues and community posts:

- **Issue**: Some users report buildCommand ignored with pnpm workspaces ([Discussion #5171]( Ignore build step · vercel/vercel · Discussion #5171 · GitHub ))

- **Pattern**: `cd ../.. && pnpm -F app build` is widely recommended

- **Issue**: Framework presets may override user configuration

- **Issue**: Vercel’s “Detected Turbo” auto-adjustment interferes with custom commands

4. The Ask - What Are We Missing?

We’ve exhausted most documented approaches and need community help:

Primary Questions

1. **Is buildCommand fundamentally incompatible** with Vercel’s new Turborepo detection?

2. **Should we abandon vercel.json** and use a different approach entirely?

3. **Are there undocumented flags or settings** that make buildCommand work in monorepos?

4. **Is this a known regression** in recent Vercel CLI versions (we’re using 44.7.3)?

Specific Evidence We Need

- **Working vercel.json examples** from successful pnpm+Turborepo+Vercel deployments

- **Build logs showing custom buildCommand execution** (our echo statements never appear)

- **Alternative approaches** that don’t rely on buildCommand

- **Vercel team confirmation** if this is expected behavior vs. bug

Our Environment

- **Vercel CLI**: 44.7.3

- **pnpm**: 10.4.1

- **Turborepo**: Latest

- **Node**: 22.x

- **Framework**: Hono (Edge Runtime)

- **TypeScript**: 5.8.3 with NodeNext module resolution

**Any help or insights would be greatly appreciated!** This seems like a fundamental issue affecting pnpm monorepo deployments to Vercel, and we’re hoping the community has found working solutions.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.