Unable to find production build in nextjs app with monorepo (nx)

site name: venture-club-platform

Site deploys builds fine according to the logs but api calls fail with:

This function has crashed
An unhandled error in the function code triggered the following message:

Error - Could not find a production build in the '/home/runner/work/main/main/dist/apps/platform/.next' directory. Try building your app with 'next build' before starting the production server. https://nextjs.org/docs/messages/production-start-no-build-id

Stack trace
Error: Could not find a production build in the '/home/runner/work/main/main/dist/apps/platform/.next' directory. Try building your app with 'next build' before starting the production server. https://nextjs.org/docs/messages/production-start-no-build-id
    at NextNodeServer.getBuildId (/var/task/node_modules/next/dist/server/next-server.js:165:23)
    at new Server (/var/task/node_modules/next/dist/server/base-server.js:56:29)
    at new NextNodeServer (/var/task/node_modules/next/dist/server/next-server.js:67:9)
    at getBridge (/var/task/.netlify/functions-internal/___netlify-handler/___netlify-handler.js:53:28)
    at Runtime.handler (/var/task/.netlify/functions-internal/___netlify-handler/___netlify-handler.js:93:46)
    at Runtime.handleOnceNonStreaming (file:///var/runtime/index.mjs:1089:29)

Build settings

Base directory: Not set
Build command: npx nx build platform --prod
Publish directory: dist/apps/platform/.next

Hi @ventureeng

What version of Next.Js are you using and can I ask why you didn’t set your base directory?

"next": "13.0.0",

Had another look through the logs, are these messages regarding the api pages relevant?

Could not find source file for page /api/auth/[...auth0]

and no base directory since we are using nx (a monorepo)

@SamO would appreciate any insight you could provide :pray:

I downgraded the netlify next plugin version in toml file to 4.25 and it works, 4.30 appears to have issues

I don’t believe this is an issue with the Runtime. It might be, but we haven’t been able to reproduce this yet. You should try using --skip-nx-cache flag in your build command moving forward.

However, if you’re able to provide a reproduction in the form of a repo, that would be of much help!

Ok we’ll try that next time we upgrade

1 Like