Next-server.js is not found during deployment

So I have a nextjs monorepo with pnpm and two separate next project in the apps folder (see the packet-details branch on this link). I’m building this locally then I deploy it to vercel using the CLI. At deployment I’m getting the following error in both projects:

Error: ENOENT: no such file or directory, lstat '/node_modules/next/dist/server/next-server.js'

I’m using the following stuff:

cli: 48.10.3
next: 16.0.0 (both projects)
pnpm: 10.15.1

What makes this interesting that when I check my deploymnet on vercel CLI, I do find the file in question.

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

Can you make sure your vercel.json or project settings specify the correct build output directory for each app?

For monorepos, you might need:

{
  "buildCommand": "cd apps/your-app && pnpm build",
  "outputDirectory": "apps/your-app/.next"
}

Hi @programmerpeter2, just checking in to see if you were able to resolve the “next-server.js not found” issue during your Vercel deployment or if you still need assistance. Let me know how it’s going!

Hi!

In the end, I’ve just deployed the whole thing using vercel deploy and just skipped prebuilding.

So basically worked around the issue.

Thanks for your interest.

Glad that worked for you!

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