The repro repo is available here: GitHub - makeagent/ma-next
This is a brand new Next 15.3 site using pnpm. I then moved it into a web folder to simulate a basic monorepo. The build succeeds, but loading the page fails with:
May 6, 09:29:33 AM: ERROR Unhandled Promise Rejection {“errorType”:“Runtime.UnhandledPromiseRejection”,“errorMessage”:“Error: Cannot find module ‘next/dist/server/lib/start-server.js’\nRequire stack:\n- /var/task/.netlify/dist/run/next.cjs”,“reason”:{“errorType”:“Error”,“errorMessage”:“Cannot find module ‘next/dist/server/lib/start-server.js’\nRequire stack:\n- /var/task/.netlify/dist/run/next.cjs”,“code”:“MODULE_NOT_FOUND”,“requireStack”:[“/var/task/.netlify/dist/run/next.cjs”],“stack”:[“Error: Cannot find module ‘next/dist/server/lib/start-server.js’”,“Require stack:”,“- /var/task/.netlify/dist/run/next.cjs”," at Function._resolveFilename (node:internal/modules/cjs/loader:1225:15)“,” at Function._load (node:internal/modules/cjs/loader:1055:27)“,” at TracingChannel.traceSync (node:diagnostics_channel:322:14)“,” at wrapModuleLoad (node:internal/modules/cjs/loader:220:24)“,” at Module.require (node:internal/modules/cjs/loader:1311:12)“,” at require (node:internal/modules/helpers:136:16)“,” at Object. (/var/task/.netlify/dist/run/next.cjs:498:30)“,” at Module._compile (node:internal/modules/cjs/loader:1554:14)“,” at Object..js (node:internal/modules/cjs/loader:1706:10)“,” at Module.load (node:internal/modules/cjs/loader:1289:32)“]},“promise”:{},“stack”:[“Runtime.UnhandledPromiseRejection: Error: Cannot find module ‘next/dist/server/lib/start-server.js’”,“Require stack:”,”- /var/task/.netlify/dist/run/next.cjs"," at process. (file:///var/runtime/index.mjs:1276:17)“,” at process.emit (node:events:518:28)“,” at emitUnhandledRejection (node:internal/process/promises:252:13)“,” at throwUnhandledRejectionsMode (node:internal/process/promises:388:19)“,” at processPromiseRejections (node:internal/process/promises:475:17)“,” at process.processTicksAndRejections (node:internal/process/task_queues:106:32)"]}
I’ve tried various different approaches as per the commit history of that repo, but the best outcome is that it builds, and then throws this error on launch…