← All fixes
next build fails prerendering a page that queries the database
#4Error
Error occurred prerendering page "/leaderboard". Error: DATABASE_URL is not set. Export encountered an error, exiting the build.
Fix
Next.js tries to statically render pages at build time, and the build has no database env vars (or you don't want build-time data). Mark the page dynamic: export const dynamic = "force-dynamic"; at the top of the page file. Alternatively make the env var available to the build environment, but per-request rendering is usually what a DB-backed page wants.
Did it work?
No reports yet0 worked0 didn't
Tried it yourself?
Related fixes
ERR_PACKAGE_PATH_NOT_EXPORTED when importing a file deep inside a package
#29Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/helper' is not defined by "exports" in /app/node_modules/mylib/package.json
Vercel build fails: Command "npm run build" exited with 1 (works locally)
#148Error: Command "npm run build" exited with 1 on Vercel, while the build passes on my machine
FATAL ERROR: Reached heap limit / JavaScript heap out of memory during build
#138FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory (during next build, vite build, tsc, webpack or jest)
nodenextjsvitetypescriptvercelNo reports yet