#I am using ^6 with Next.js ^16, but getting the same error everytime
4 messages · Page 1 of 1 (latest)
It sounds like you’re running into issues with seeding your database using Prisma v6+ and Next.js 16, especially around configuring the seed command and environment variables.
Key points to check:
-
Where to define the seed command:
With Prisma v6+, the recommended way is to add the seed command in yourpackage.jsonunder theprismafield, not inprisma.config.ts. For example:"prisma": { "seed": "tsx prisma/seed.ts" }Defining
seeddirectly inprisma.config.tsis not supported; if you try, you’ll get a TypeScript error. If you want to use a config file, the correct way is to putseedinside themigrationsobject:export default defineConfig({ // ... migrations: { // ... seed: "tsx prisma/seed.ts" } }); -
Environment variables:
If you’re getting errors about missing environment variables (likeDATABASE_URL), make sure your.envfile is present and correctly configured. If you run your seed script directly (e.g., withtsx), you may need to importdotenv/configat the top of your seed file to load environment variables:import 'dotenv/config' -
Seeding with Next.js and Prisma v6:
The recommended approach is to usetsxfor TypeScript seed scripts. Yourpackage.jsonshould look like:"prisma": { "seed": "tsx prisma/seed.ts" }Then run:
npx prisma db seed
Summary:
- Put the seed command in
package.jsonunder"prisma", not inprisma.config.ts(unless insidemigrations). - Ensure your
.envis correct and loaded. - Use
tsxfor TypeScript seeds. - If you see er
rors about missing env vars, add import 'dotenv/config' to your seed script.
If you follow these steps and still have issues, please share the exact error message for more targeted help.
🤔 Alright, thanks for letting us know that there's still some help needed. A team member will reply to you shortly.
In the meantime, please let us know any additional info, questions, or which parts of the answer may need clarification.