node.jstypescriptprisma

Prisma 7.0.1 : TypeError: Cannot read properties of undefined (reading '__internal')


I was using Prisma 6, and after upgrading to Prisma 7 I had to apply some changes to my schema.prisma. These changes include modifying the schema.prisma file and adding a new prisma.config.ts file.

My current schema.prisma looks like this:

generator client {
  provider = "prisma-client"
  output   = "../src/generated/prisma"
}

datasource db {
  provider = "postgresql"
}

And my prisma.config.ts file looks like this:

import "dotenv/config";
import { defineConfig, env } from "prisma/config";

export default defineConfig({
  schema: "prisma/schema.prisma",
  migrations: {
    path: "prisma/migrations",
  },
  datasource: {
    url: env("DATABASE_URL"),
  },
});

But after adding, in this code I have this error:

import { PrismaClient } from '@prisma/client'

const prisma = new PrismaClient()

export default prisma

//error:    
//    config = optionsArg.__internal?.configOverride?.(config) ?? config
                              ^
//    TypeError: Cannot read properties of undefined (reading '__internal')

Solution

  • This error comes from a breaking change introduced in Prisma 7. The Prisma Client constructor no longer works without a driver adapter, which means calling:

    const client = new PrismaClient()
    

    Now fails because Prisma expects an adapter option.

    The upgrade notes explain this in detail: https://www.prisma.io/docs/orm/more/upgrade-guides/upgrading-versions/upgrading-to-prisma-7#driver-adapters-and-client-instantiation

    Since my project uses SQLite, I had to switch to:

    const client = new PrismaClient({
      adapter: new PrismaBetterSqlite3({
        url: 'file:./prisma/dev.db',
      }),
    });