Issue: Prisma 7 prisma failing on Vercel with "Missing required environment variable: DATABASE_URL

Environment: Prisma ORM v7.0.0 (upgraded from v6.19) Next.js 16.0.3 Turborepo monorepo with pnpm Database package location: database Error during Vercel build: Failed to load config file "/vercel/path0/packages/database" as a TypeScript/JavaScript module. Error: PrismaConfigEnvError: Missing required environment variable: DATABASE_URL Configuration: DATABASE_URL IS set in Vercel environment variables (for Production, Preview, and Development) Using prisma.config.ts with import 'dotenv/config' and env("DATABASE_URL") as per Prisma v7 docs dotenv package is installed .env file with DATABASE_URL exists locally in .env (but gitignored) What worked: Everything worked fine with Prisma v6.19 Local development works perfectly The issue only occurs on Vercel during turbo run build → db:generate step What I've tried: Verified DATABASE_URL is set in Vercel dashboard Confirmed dotenv is installed in dependencies Following exact Prisma v7 documentation for monorepos Configuration matches official examples
No description
4 Replies
Prisma AI Help
You're in no rush, so we'll let a dev step in. Enjoy your coffee, or drop into #ask-ai if you get antsy for a second opinion!
Aman
Aman7d ago
By default, dotenv only loads environment variables from the root of the working directory. In a monorepo, you can point it to the actual location of your .env file by specifying a custom path, like this: dotenv.config({ path: '../apps/server/.env' });
No description
Parwar Yassin
Parwar YassinOP5d ago
i have manged to fix it simply by this
No description
Nurul
Nurul4d ago
Nice to see that you were able to fix this 👍

Did you find this page helpful?