NextJS + Turborepo installs after building


I am jhaving this issue where Vercel reruns my install after it already finished the build when using NextJS 15.2.2 + Turborepo.

Never had this happened before

Note: I do not have a custom vercel.json but I do have a custom build command & custom install command and the custom install command is not being respected by the “Installing dependecies…” in the picture

Hey!
It looks like you’re experiencing some issues with your custom build/installation process since it’s not working as expected. To better troubleshoot this problem, I’d recommend running each step of the process separately. This approach should help you pinpoint exactly where things are breaking down.

We were able to take a look at the deployment based on those logs and it looks like you have a directory called api/ in the application that is invoking the Node.js builder. However, the application is a Next.js app using the Next.js Framework preset - so the Next.js builder is also being invoked!

We suggest you move the api/ directory into the Next.js application following Next.js Route Handler conventions. This will make it so the Node.js builder stops running, resolving this issue.

1 Like

Thanks for looking into it!

I am already using the NextJS way to write apis ( use route.ts under the app folder and export a GET/POST method to handle the request). The route files do import functions from a package in the monorepo but I don’t see how this could be an issue.

Still don’t understand what do you mean by you have a directory called api/ in the application that is invoking the Node.js builder as the routes are in the NextJS app folder

Let me know if you need more information about the project structure I am open to send it to you privately or via email

Ok so after carefully looking again, I had accidentally created an api folder outside the nextjs appfolder

So my nextjs project was in the “project” folder in my turborepo project the api folder was:

|-project
 |- api
 |- app

Instead of being like this:

|- project
 |- app
  |- api

So in short, make sure that you are api folder is inside the app folder. I am still curious to how does NextJS/ Vercel interpret that endpoint, will look into it eventually haha