I'm still having this problem in NextJS that the seeding isn't being executed correctly. When I run npx prisma db seed
, no errors are thrown, but the seed isn't being executed.
When I try to start the seed.ts file manually via npx tsx prisma/seed.ts
, I get this error:
error: Environment variable not found: DATABASE_URL.
--\> schema.prisma:3
|
2 | provider = āpostgresqlā
3 | url = env(āDATABASE_URLā)
|
This is what my prisma.config.ts file looks like
import 'dotenv/config';
import path from 'node:path';
import { defineConfig } from 'prisma/config';
export default defineConfig({
schema: path.join('prisma', 'schema.prisma'),
migrations: {
path: path.join('prisma', 'migrations'),
seed: 'tsx prisma/seed.ts',
},
});
It also doesn't matter whether I use tsx prisma/seed.ts
or npx tsx prisma/seed.ts
as the seed command in the config file, neither works.
Any solutions? Do I need to adjust something else in the seed.ts
file?