The production-only failure is a good reminder to run next build and next start before upgrading. I hit a similar Turbopack and database driver problem with pg, where bundling it broke long lived connections, and listing pg in serverExternalPackages fixed it. It might be worth trying for the dynamic require case too, if you'd rather not import the driver by hand.
Finally got around to checking this! Turns out pg was already in serverExternalPackages when the build dropped it. That prevents it from being bundled, but Next.js still couldn't follow TypeORM's dynamic require() when tracing files, so pg never made it into the standalone output. Passing driver: pg directly is what actually fixed it.
Tarun Sharma
React.js Frontend Web Developer | Next.js Specialist
The production-only failure is a good reminder to run next build and next start before upgrading. I hit a similar Turbopack and database driver problem with pg, where bundling it broke long lived connections, and listing pg in serverExternalPackages fixed it. It might be worth trying for the dynamic require case too, if you'd rather not import the driver by hand.