None of the mongoose examples with NextJS 14 are working on prod, just take your example and do “npm run build” , and you will get the same error that I am getting:
./lib/db.ts
Dynamic Code Evaluation (e. g. ‘eval’, ‘new Function’, ‘WebAssembly.compile’) not allowed in Edge Runtime
Learn More: Dynamic code evaluation is not available in Middleware | Next.js
The error was caused by importing ‘mongoose/dist/browser.umd.js’ in ‘./lib/db.ts’.
you can write me at: dvirben123@gmail.com , and I will give you access to my repo in order to see this error.