prismaAdapter not working with generator output #1171

Closed
opened 2026-03-13 08:26:25 -05:00 by GiteaMirror · 4 comments
Owner

Originally created by @MayiVT on GitHub (May 6, 2025).

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

  1. Create a new project (In this case Hono)
  2. Install prisma database
  3. on schema.prisma set an output generator (as will be required on prisma 7)
  4. run bunx @better-auth/cli generate

Current vs. Expected behavior

Current behavior

mayin3ko@MacBook-Pro-de-Mayi NeuroProof-core % bunx @better-auth/cli generate
2025-05-06T20:32:40.858Z ERROR [Better Auth]: [#better-auth]: Couldn't read your auth config. Error: @prisma/client did not initialize yet. Please run "prisma generate" and try to import it again.
    at new PrismaClient (/Users/mayin3ko/Documents/GitHub/NeuroProof-core/node_modules/.prisma/client/default.js:43:11)
    at /Users/mayin3ko/Documents/GitHub/NeuroProof-core/src/lib/db.ts:5:51
    at async import (/private/tmp/bunx-501-@better-auth/cli@latest/node_modules/jiti/dist/jiti.cjs:1:199772)
    at async /Users/mayin3ko/Documents/GitHub/NeuroProof-core/src/lib/auth.ts:2:11
    at async Function.import (/private/tmp/bunx-501-@better-auth/cli@latest/node_modules/jiti/dist/jiti.cjs:1:199772)
    at async resolveConfig (file:///private/tmp/bunx-501-@better-auth/cli@latest/node_modules/c12/dist/shared/c12.PQMoYrit.mjs:346:18)
    at async loadConfig (file:///private/tmp/bunx-501-@better-auth/cli@latest/node_modules/c12/dist/shared/c12.PQMoYrit.mjs:146:23)
    at async getConfig (file:///private/tmp/bunx-501-@better-auth/cli@latest/node_modules/@better-auth/cli/dist/index.mjs:234:30)
    at async Command.generateAction (file:///private/tmp/bunx-501-@better-auth/cli@latest/node_modules/@better-auth/cli/dist/index.mjs:725:18)

Expected behavior

mayin3ko@MacBook-Pro-de-Mayi NeuroProof-core % bunx @better-auth/cli generate
✔ The file ./prisma/schema.prisma already exists. Do you want to overwrite the schema to the file? … yes
2025-05-06T20:35:46.407Z SUCCESS [Better Auth]: 🚀 Schema was overwritten successfully!

What version of Better Auth are you using?

1.2.7

Provide environment information

- OS: [Mac OSX]

Which area(s) are affected? (Select all that apply)

Other

Auth config (if applicable)

import { betterAuth } from "better-auth";
import { prismaAdapter } from "better-auth/adapters/prisma";
import { PrismaClient } from "@prisma/client";
 
const prisma = new PrismaClient();
export const auth = betterAuth({
    database: prismaAdapter(db, {
        provider: "mysql"
    })
})

Additional context

The issue was fixed when removing the output generator from prisma

Originally created by @MayiVT on GitHub (May 6, 2025). ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce 1. Create a new project (In this case Hono) 2. Install prisma database 3. on schema.prisma set an output generator (as will be required on prisma 7) 4. run `bunx @better-auth/cli generate` ### Current vs. Expected behavior **Current behavior** ``` mayin3ko@MacBook-Pro-de-Mayi NeuroProof-core % bunx @better-auth/cli generate 2025-05-06T20:32:40.858Z ERROR [Better Auth]: [#better-auth]: Couldn't read your auth config. Error: @prisma/client did not initialize yet. Please run "prisma generate" and try to import it again. at new PrismaClient (/Users/mayin3ko/Documents/GitHub/NeuroProof-core/node_modules/.prisma/client/default.js:43:11) at /Users/mayin3ko/Documents/GitHub/NeuroProof-core/src/lib/db.ts:5:51 at async import (/private/tmp/bunx-501-@better-auth/cli@latest/node_modules/jiti/dist/jiti.cjs:1:199772) at async /Users/mayin3ko/Documents/GitHub/NeuroProof-core/src/lib/auth.ts:2:11 at async Function.import (/private/tmp/bunx-501-@better-auth/cli@latest/node_modules/jiti/dist/jiti.cjs:1:199772) at async resolveConfig (file:///private/tmp/bunx-501-@better-auth/cli@latest/node_modules/c12/dist/shared/c12.PQMoYrit.mjs:346:18) at async loadConfig (file:///private/tmp/bunx-501-@better-auth/cli@latest/node_modules/c12/dist/shared/c12.PQMoYrit.mjs:146:23) at async getConfig (file:///private/tmp/bunx-501-@better-auth/cli@latest/node_modules/@better-auth/cli/dist/index.mjs:234:30) at async Command.generateAction (file:///private/tmp/bunx-501-@better-auth/cli@latest/node_modules/@better-auth/cli/dist/index.mjs:725:18) ``` **Expected behavior** ``` mayin3ko@MacBook-Pro-de-Mayi NeuroProof-core % bunx @better-auth/cli generate ✔ The file ./prisma/schema.prisma already exists. Do you want to overwrite the schema to the file? … yes 2025-05-06T20:35:46.407Z SUCCESS [Better Auth]: 🚀 Schema was overwritten successfully! ``` ### What version of Better Auth are you using? 1.2.7 ### Provide environment information ```bash - OS: [Mac OSX] ``` ### Which area(s) are affected? (Select all that apply) Other ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth"; import { prismaAdapter } from "better-auth/adapters/prisma"; import { PrismaClient } from "@prisma/client"; const prisma = new PrismaClient(); export const auth = betterAuth({ database: prismaAdapter(db, { provider: "mysql" }) }) ``` ### Additional context The issue was fixed when removing the output generator from prisma
Author
Owner

@Snazzie commented on GitHub (May 6, 2025):

Ive nothing but issues with prisma. Use drizzle instead.

@Snazzie commented on GitHub (May 6, 2025): Ive nothing but issues with prisma. Use drizzle instead.
Author
Owner

@Asuniia commented on GitHub (May 8, 2025):

Image

Same

@Asuniia commented on GitHub (May 8, 2025): <img width="1018" alt="Image" src="https://github.com/user-attachments/assets/a1992bd2-3321-42bc-b36c-d717e748cc02" /> Same
Author
Owner

@Kinfe123 commented on GitHub (May 12, 2025):

can you please show me your prisma schema file ?

@Kinfe123 commented on GitHub (May 12, 2025): can you please show me your prisma schema file ?
Author
Owner

@nazebzurati commented on GitHub (May 14, 2025):

Based on your attached code, my suggestion as follows:

import { betterAuth } from "better-auth";
import { prismaAdapter } from "better-auth/adapters/prisma";
// import { PrismaClient } from "@prisma/client";
import { PrismaClient } from "../../generated/prisma"; // use generator client output path from your schema.prisma
 
const prisma = new PrismaClient();

export const auth = betterAuth({
    // database: prismaAdapter(db, {
    database: prismaAdapter(prisma, { // should be prisma
        provider: "mysql"
    })
})
@nazebzurati commented on GitHub (May 14, 2025): Based on your attached code, my suggestion as follows: ```ts import { betterAuth } from "better-auth"; import { prismaAdapter } from "better-auth/adapters/prisma"; // import { PrismaClient } from "@prisma/client"; import { PrismaClient } from "../../generated/prisma"; // use generator client output path from your schema.prisma const prisma = new PrismaClient(); export const auth = betterAuth({ // database: prismaAdapter(db, { database: prismaAdapter(prisma, { // should be prisma provider: "mysql" }) }) ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#1171