Turborepo and Vercel build issue ENOENT: no such file or directory

When merging my branch upstream I run into this build error on Vercel using Turborepo and Next.js:

Tasks: 2 successful, 2 total
Cached: 2 cached, 2 total
Time: 2.221s >>> FULL TURBO
Summary: /vercel/path0/.turbo/runs/39PHPeF2uVdvebKyrgX8wVHabDk.json
Traced Next.js server files in: 333.267ms
Error: ENOENT: no such file or directory, lstat '/vercel/path0/node_modules/jszip/node_modules/lie/lib/index.js'

Setup:

  • Package manager: Bun
  • Using Turborepo with Next.js

Root turbo.json configuration:

"build": {
  "dependsOn": ["^build"],
  "inputs": ["$TURBO_DEFAULT$", ".env*"],
  "outputs": [".next/**", "!.next/cache/**"]
}

The error seems to be related to a nested dependency (jszip → lie) not being found during the Vercel build process. The build works locally but fails when deployed to Vercel after merging upstream.

It works when I do a redeploy without build cache on vercel.

I have set my root directory to apps/dashboard where my next.js app is located in the repo.

This error means it can’t find the file, and most likely it means it can’t find any node_modules

If you are passing .vercel and .next to the deploy layer, you’ll need to either

  • install modules in the deploy layer

  • or pass node_modules from build into the deploy layer

1 Like

Thanks for the response! I think I saw the same message duplicated in another thread. But could you clarify what you mean by “deploy layer”? If there’s documentation on how to configure this, I’d appreciate a link.


Update: I believe I found the root cause

I had numerous packages listed in serverExternalPackages in my next.config.ts that are no longer needed in our application. This may also be related to recent improvements in Turbopack’s bundling behavior.

After removing these entries, the build appears to work correctly:

const nextConfig = {
  //...
  serverExternalPackages: [
     "pino",
      "pino-pretty",
      // Fix bundling warnings for legacy packages
      "fstream",
      "rimraf",
      "glob",
      "minimatch",
      "brace-expansion",
      // ExcelJS and its dependencies
      "exceljs",
      "jszip",
      "lie",
      "unzipper",
      "minimatch",
      "graphql",
      "@aws-amplify/pubsub",
      "@aws-amplify/api-graphql",
      "@sentry/node",
  ]
}

export default nextConfig;

This fix isn’t 100% confirmed yet, but I’ll monitor the builds throughout the day and update if I encounter any issues.

1 Like

Hi Paul, thanks for sharing your interim solution. Feel free to post here if you come across this issue again.

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