#I am using ^6 with Next.js ^16, but getting the same error everytime

4 messages · Page 1 of 1 (latest)

white martenBOT
#

You selected the bot's instantaneous insights. Let me compile your answer right away!

white martenBOT
# white marten You selected the bot's instantaneous insights. Let me compile your answer right ...

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:

  1. Where to define the seed command:
    With Prisma v6+, the recommended way is to add the seed command in your package.json under the prisma field, not in prisma.config.ts. For example:

    "prisma": {
      "seed": "tsx prisma/seed.ts"
    }
    

    Defining seed directly in prisma.config.ts is not supported; if you try, you’ll get a TypeScript error. If you want to use a config file, the correct way is to put seed inside the migrations object:

    export default defineConfig({
      // ...
      migrations: {
        // ...
        seed: "tsx prisma/seed.ts"
      }
    });
    

    See: Issue about config file confusion

  2. Environment variables:
    If you’re getting errors about missing environment variables (like DATABASE_URL), make sure your .env file is present and correctly configured. If you run your seed script directly (e.g., with tsx), you may need to import dotenv/config at the top of your seed file to load environment variables:

    import 'dotenv/config'
    

    See: Environment variable issues

  3. Seeding with Next.js and Prisma v6:
    The recommended approach is to use tsx for TypeScript seed scripts. Your package.json should look like:

    "prisma": {
      "seed": "tsx prisma/seed.ts"
    }
    

    Then run:

    npx prisma db seed
    

    See: Official Next.js + Prisma v6 guide

Summary:

  • Put the seed command in package.json under "prisma", not in prisma.config.ts (unless inside migrations).
  • Ensure your .env is correct and loaded.
  • Use tsx for TypeScript seeds.
  • If you see er
white martenBOT
white martenBOT