Error: ENOENT: no such file or directory, lstat on build file

First vercel deploy on a project that builds and runs locally.

Error: ENOENT: no such file or directory, lstat ‘/vercel/path0/apps/web/.next/server/app/(marketing)/page_client-reference-manifest.js’

page_client-reference-manifest.js is a file that should be generated during build. I have confirmed that the path has the appropriate files in place to build.

Any suggestions appreciated.

So the cause was a page.tsx in the root of (marketing) that I added on purpose to perform a redirect. Once removed this error disappears and the app could build.

At this time I do not understand why. But I suspect it has something to do with the dark science of routing.

Hi @garthboyd-devious-pl, welcome to the Vercel Community!

I’m glad you solved the issue.

Can you share the code that caused the error?

The code was a simple redirect in a page.tsx file residing in the apps/web/app directory.

import { redirect } from 'next/navigation';

export default function Page() {
  redirect('/auth/sign-in');
}

I moved the redirect to middleware and removed this file. Also of note was that the build error did not occur in my local dev environment.

Hi @garthboyd-devious-pl, thanks for sharing additional information. Can you also share your project directory structure? Because app/page.tsx and app/(marketing)/page.tsx would both resolve to / and cause an error. For more information, see Routing: Route Groups | Next.js.

Hi Anshuman,

Thanks for following up on this.

I am using the Makerkit.dev framework if you are familiar with it. So the full path in the repo was:

/apps/web/app/page.tsx

Hope this helps. I am curious where you are going with this =)

Cheers,
Garth