- Symptom
- Error: PrismaConfigEnvError: Cannot resolve environment variable: DATABASE_URL.Error: PrismaConfigEnvError: Missing required environment variable: DATABASE_URLA typecheck-only CI job that never touches the database now needs a database URL
- Cause
- Prisma 7 loads prisma.config.ts for every CLI command, and env() from prisma/config throws when the variable is unset, even for generate. Prisma 7 also stopped reading the env file automatically, so the config has to load dotenv itself.
- Fix
- Import dotenv/config at the top of the config and read process.env directly, so generate runs without a URL while migrate commands still fail with a clear message.
- Apply
import 'dotenv/config' import { defineConfig } from 'prisma/config' export default defineConfig({ schema: 'prisma/schema.prisma', migrations: { path: 'prisma/migrations' }, datasource: { url: process.env.DATABASE_URL }, })- Affected
- Prisma ORM 7.0 and later; the process.env form is accepted by 7.8.0 and later and was verified on 7.10.0
- Sources
Last verified 2026-10-15 · Confirmed by 0 builders