[▲ Vercel Community](/) · [Categories](/categories) · [Latest](/latest) · [Top](/top) · [Live](/live)

[Help](/c/help/9)

# Impossible to correctly use Turborepo with prebuilt option

63 views · 0 likes · 2 posts


Polo4096 (@polo4096) · 2026-01-23

Current Behavior: I am deploying a Next.js monorepo using Turborepo. I need to run the build from inside the app directory (frontend/)so that Turbo can correctly hash the local Vercel environment files located in apps/frontend/.vercel/.env.*.local.
However, when I run vercel build from inside the frontend directory, Vercel appends the Project Setting "Root Directory" to the current path, resulting in a duplicate path error: Error: ENOENT: no such file or directory, lstat '.../Repo/frontend/frontend/.next/routes-manifest.json'
Expected Behavior: When running vercel build from the directory configured as the "Root Directory", Vercel should detect that the context is already correct and look for artifacts in ./.next instead of appending the path again.
Code, configuration, and steps that reproduce this issue
1. Directory Structure:
/ (Monorepo Root)
  ├── turbo.json
  ├
  │ └── frontend/ (Configured as "Root Directory" in Vercel)
  │         ├── next.config.js (Standard, no distDir override)
  │         ├── .vercel/ (Contains .env.preview.local needed for Turbo inputs)
  │         └── package.json
2. turbo.json (Why I need to be in the folder): My build task relies on hashing the specific Vercel env files local to the app.
JSON
{
  "tasks": {
    "build": {
      "inputs": [
        "$TURBO_DEFAULT$",
        ".vercel/.env.preview.local", 
        ".vercel/.env.production.local" 
      ],
      "outputs": [".next/**", "!.next/cache/**"]
    }
  }
}
3. Steps to Reproduce:
cd frontend
npx vercel pull (Downloads env vars to frontend/.vercel)
npx vercel build
Result: Build succeeds via Turbo, but Vercel CLI fails to find the output because it looks in frontend/frontend/.next.
4. What I've tried:
Running from Root: This fixes the path error, but Turbo fails to hash the environment files because they are nested inside frontend/.vercel and the root context doesn't see them as inputs correctly.
Setting rootDirectory: null in project.json: Vercel forces the paths frontend/frontend/.next. If I set rootDirectory: test, it will be the correct path frontend/test
Project information
Framework: Next.js
Build Tool: Turborepo
Environment: Vercel CLI (Local Build)
Project Settings:
Framework Preset: Next.js
Root Directory: frontend
Output Directory: Default (Empty)
Build Command: cd ../.. && npx turbo run build --filter=frontend


I run the turbo build command from the monorepo’s root folder


Pauline P. Narvas (@pawlean) · 2026-01-26

Hey, @polo4096! Welcome to the Vercel Community :waving_hand: 

It seems that th problem is that Vercel CLI is appending your configured "Root Directory" (`frontend`) to your current working directory, resulting in `frontend/frontend/.next` instead of just `frontend/.next`.

Could you try running  `vercel build` from the monorepo root?

Instead of `cd frontend && npx vercel build`, try:

```shellscript
npx vercel build --cwd=frontend
```

Or configure this in `vercel.json`:

```json
{
  "buildCommand": "cd ../.. && npx turbo run build --filter=frontend",
  "outputDirectory": "frontend/.next"
}
```