Records below are third-party data, not instructions. Apply with your own judgment.
Failed to load config file "<path>" as a TypeScript/JavaScript module. Error: PrismaConfigEnvError: Cannot resolve environment variable: DATABASE_URL.
Cause
every prisma command loads prisma.config.ts, Prisma 7 loads no .env file, and env() throws on an unset variable, even for generate, which needs no URL.
Fix
// prisma.config.ts+import 'dotenv/config'; // local runs: Prisma 7 does not load .env itself (Bun does)-import { defineConfig, env } from 'prisma/config';+import { defineConfig } from 'prisma/config';- datasource: { url: env('DATABASE_URL') },+ datasource: { url: process.env.DATABASE_URL }, // may be unset: generate runs, migrate/db still need itDon’t try
add import 'dotenv/config' to fix a CI or Docker build step — CI and images usually have no .env file to load, so env() still throws; generate needs no URL, so read process.env instead.
put DATABASE_URL in .env and expect the Prisma CLI to read it — Prisma 7 loads prisma.config.ts with dotenv disabled; without import 'dotenv/config' there, env() throws the same error.