Error: The BUILD_ID file was not found in the Output Directory. Did you forget to run "next build" in your Build Command?

Hey everyone :wave:

Trying to deploy a Turborepo project to Vercel and while build is generated successfully, I’m getting error Error: The BUILD_ID file was not found in the Output Directory. Did you forget to run "next build" in your Build Command? in the end of the build step and of course it doesn’t deploy.

Locally tho, BUILD_ID is present inside .next directory and I can successfully run npm run start with Turborepo.

Below is my turbo.json

{
  "$schema": "https://turbo.build/schema.json",
  "globalEnv": [
    "NODE_ENV",
    "DATABASE_URL"
  ],
  "ui": "tui",
  "tasks": {
    "build": {
      "dependsOn": [
        "^build"
      ],
      "outputs": [
        ".next/**",
        "!.next/cache/**"
      ],
      "env": [
        "NEXT_PUBLIC_SUPABASE_ANON_KEY",
        "NEXT_PUBLIC_SUPABASE_URL",
        "NEXT_PUBLIC_STRIPE_KEY",
        "STRIPE_API_KEY",
        "NEXT_PRUBLIC_CART_CANCEL_URL",
        "NEXT_PUBLIC_CART_SUCCESS_URL",
        "TEACHWORKS_API_KEY",
        "UPSTASH_KAFKA_REST_PASSWORD",
        "UPSTASH_KAFKA_REST_URL",
        "UPSTASH_KAFKA_REST_USERNAME",
        "KAFKA_BROKER",
        "KAFKA_USERNAME",
        "KAFKA_PASSWORD",
        "MONGODB_URI",
        "RESEND_API_KEY",
        "SENTRY_AUTH_TOKEN",
        "CLERK_SECRET_KEY",
        "NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY",
        "NEXTAUTH_SECRET",
        "WEBHOOK_SECRET",
        "NEXT_PUBLIC_BASE_URL",
        "DIRECT_URL"
      ]
    },
    "db:generate": {
      "cache": false
    },
    "db:migrate": {
      "cache": false
    },
    "db:push": {
      "cache": false
    },
    "ios": {
      "cache": false
    },
    "check-types": {
      "dependsOn": [
        "^check-types"
      ]
    },
    "dev": {
      "persistent": true,
      "dependsOn": [
        "^db:generate"
      ],
      "cache": false,
      "inputs": [
        ".env"
      ]
    }
  }
}

I’m pretty new to Turborepo setup, but this is the first time I see error like this with Vercel

Also, running vercel build locally gave me the same error and the content of .turbo/runs is showing that there’s BUILD_ID in the expandedOutputs

        "apps/next/.next",
        "apps/next/.next/BUILD_ID",
        "apps/next/.next/app-build-manifest.json",
        "apps/next/.next/app-path-routes-manifest.json",
        "apps/next/.next/build-manifest.json",

This is likely because the Root Directory is not set for the project in the monorepo, so the build outputs don’t exist in the expected place.

Does setting the Root Directory help?

3 Likes

Hey Anthony! Yes, you’re right! Setting Root Directory to apps/{next_dir} helped and everything is working properly!

Thanks!

1 Like

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