[GH-ISSUE #3736] Can not generate Prisma schema using CLI #9705

Closed
opened 2026-04-13 05:21:44 -05:00 by GiteaMirror · 11 comments
Owner

Originally created by @st-hungdinh on GitHub (Aug 1, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/3736

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

I try to use npx @better-auth/cli generate but have no response when i execute

  • Prisma schema config:
generator client {
  provider = "prisma-client-js"
  output   = "../src/generated/prisma"
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

  • Auth config:
import { betterAuth } from 'better-auth';
import { prismaAdapter } from 'better-auth/adapters/prisma';
import { db } from './db';

export const auth = betterAuth({
  database: prismaAdapter(db, {
    provider: 'postgresql', // or "mysql", "postgresql", ...etc
  }),
});

Current vs. Expected behavior

Command creates the schema required by Better Auth

What version of Better Auth are you using?

^1.3.4

Provide environment information

- Mac M1

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

Documentation, Backend

Auth config (if applicable)

import { betterAuth } from 'better-auth';
import { prismaAdapter } from 'better-auth/adapters/prisma';
import { db } from './db';

export const auth = betterAuth({
  database: prismaAdapter(db, {
    provider: 'postgresql', // or "mysql", "postgresql", ...etc
  }),
});

Additional context

No response

Originally created by @st-hungdinh on GitHub (Aug 1, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/3736 ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce I try to use `npx @better-auth/cli generate` but have no response when i execute - Prisma schema config: ``` generator client { provider = "prisma-client-js" output = "../src/generated/prisma" } datasource db { provider = "postgresql" url = env("DATABASE_URL") } ``` - Auth config: ``` import { betterAuth } from 'better-auth'; import { prismaAdapter } from 'better-auth/adapters/prisma'; import { db } from './db'; export const auth = betterAuth({ database: prismaAdapter(db, { provider: 'postgresql', // or "mysql", "postgresql", ...etc }), }); ``` ### Current vs. Expected behavior Command creates the schema required by Better Auth ### What version of Better Auth are you using? ^1.3.4 ### Provide environment information ```bash - Mac M1 ``` ### Which area(s) are affected? (Select all that apply) Documentation, Backend ### Auth config (if applicable) ```typescript import { betterAuth } from 'better-auth'; import { prismaAdapter } from 'better-auth/adapters/prisma'; import { db } from './db'; export const auth = betterAuth({ database: prismaAdapter(db, { provider: 'postgresql', // or "mysql", "postgresql", ...etc }), }); ``` ### Additional context _No response_
GiteaMirror added the locked label 2026-04-13 05:21:44 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Aug 1, 2025):

Hi @st-hungdinh! I'm Dosu and I’m helping the better-auth team.

The CLI generate command requires a config file (usually auth.ts) that exports your Better Auth instance. If the CLI can't find this file, it may exit silently or show no output—this matches what you're seeing. You can explicitly specify the config file with --config, like:

npx @better-auth/cli generate --config ./path/to/auth.ts

If you don't see any output, the CLI might be waiting for confirmation to overwrite or append to an existing schema file. Use the --yes flag to skip prompts:

npx @better-auth/cli generate --config ./path/to/auth.ts --yes

The generated schema (for Prisma) will usually be written to prisma/schema.prisma unless you set a different output path with --output citation.

If you still get no output, double-check that your auth.ts is in the project root or the path you specify, and that it directly exports the Better Auth instance without wrappers. The CLI only supports built-in adapters (prisma, drizzle, kysely); if you use a custom adapter, it must implement a createSchema method or the CLI will exit without generating anything citation.

Known issue: the generated schema may mark the name field as NOT NULL, which can break email/password signup unless you make it optional in your schema citation.

If you use custom fields or types (like json), make sure they're supported for your database provider, or you might get a type mapping error citation.

Let me know if specifying --config and --yes helps, or if you see any error output with those flags.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

<!-- gh-comment-id:3144132859 --> @dosubot[bot] commented on GitHub (Aug 1, 2025): <!-- Greeting --> Hi @st-hungdinh! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the better-auth team. <!-- Answer --> The CLI `generate` command requires a config file (usually `auth.ts`) that exports your Better Auth instance. If the CLI can't find this file, it may exit silently or show no output—this matches what you're seeing. You can explicitly specify the config file with `--config`, like: ``` npx @better-auth/cli generate --config ./path/to/auth.ts ``` If you don't see any output, the CLI might be waiting for confirmation to overwrite or append to an existing schema file. Use the `--yes` flag to skip prompts: ``` npx @better-auth/cli generate --config ./path/to/auth.ts --yes ``` The generated schema (for Prisma) will usually be written to `prisma/schema.prisma` unless you set a different output path with `--output` [citation](https://github.com/better-auth/better-auth/issues/3549). If you still get no output, double-check that your `auth.ts` is in the project root or the path you specify, and that it directly exports the Better Auth instance without wrappers. The CLI only supports built-in adapters (prisma, drizzle, kysely); if you use a custom adapter, it must implement a `createSchema` method or the CLI will exit without generating anything [citation](https://github.com/better-auth/better-auth/issues/3003). Known issue: the generated schema may mark the `name` field as `NOT NULL`, which can break email/password signup unless you make it optional in your schema [citation](https://github.com/better-auth/better-auth/issues/3394). If you use custom fields or types (like `json`), make sure they're supported for your database provider, or you might get a type mapping error [citation](https://github.com/better-auth/better-auth/issues/3602). Let me know if specifying `--config` and `--yes` helps, or if you see any error output with those flags. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/c6101b58-4d85-4d6c-9644-5dce920b2a66?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/c6101b58-4d85-4d6c-9644-5dce920b2a66?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/c6101b58-4d85-4d6c-9644-5dce920b2a66?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/c6101b58-4d85-4d6c-9644-5dce920b2a66?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/c6101b58-4d85-4d6c-9644-5dce920b2a66?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/c6101b58-4d85-4d6c-9644-5dce920b2a66?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/c6101b58-4d85-4d6c-9644-5dce920b2a66?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/better-auth/better-auth/issues/3736)
Author
Owner

@Kinfe123 commented on GitHub (Aug 1, 2025):

you mean even there is no error log ?

<!-- gh-comment-id:3144302646 --> @Kinfe123 commented on GitHub (Aug 1, 2025): you mean even there is no error log ?
Author
Owner

@hungds99 commented on GitHub (Aug 1, 2025):

@Kinfe123 Yes, I tried another CLI but it was the same issue:

Image
<!-- gh-comment-id:3144319368 --> @hungds99 commented on GitHub (Aug 1, 2025): @Kinfe123 Yes, I tried another CLI but it was the same issue: <img width="686" height="344" alt="Image" src="https://github.com/user-attachments/assets/962a82cc-c394-4199-a2c9-787133df74dc" />
Author
Owner

@Kinfe123 commented on GitHub (Aug 1, 2025):

is there any diff with this - npx @better-auth/cli generate ?

<!-- gh-comment-id:3144335226 --> @Kinfe123 commented on GitHub (Aug 1, 2025): is there any diff with this - `npx @better-auth/cli generate` ?
Author
Owner

@hungds99 commented on GitHub (Aug 1, 2025):

The same, there are no response any log

Image
<!-- gh-comment-id:3144343050 --> @hungds99 commented on GitHub (Aug 1, 2025): The same, there are no response any log <img width="746" height="501" alt="Image" src="https://github.com/user-attachments/assets/3d1d8423-87f2-4eb8-a0e2-0a0154e10b90" />
Author
Owner

@Kinfe123 commented on GitHub (Aug 1, 2025):

Do you have you Auth file and prisma file setup already ?

<!-- gh-comment-id:3144346376 --> @Kinfe123 commented on GitHub (Aug 1, 2025): Do you have you Auth file and prisma file setup already ?
Author
Owner

@hungds99 commented on GitHub (Aug 1, 2025):

i already have

Image
<!-- gh-comment-id:3144364284 --> @hungds99 commented on GitHub (Aug 1, 2025): i already have <img width="1680" height="956" alt="Image" src="https://github.com/user-attachments/assets/6daa8d44-99f7-46d8-845b-6c73802abfe7" />
Author
Owner

@Kinfe123 commented on GitHub (Aug 1, 2025):

is this open-source ? i cant seem to repro this. can you do some reproducible repo to this ? like the copy of this project

<!-- gh-comment-id:3144473889 --> @Kinfe123 commented on GitHub (Aug 1, 2025): is this open-source ? i cant seem to repro this. can you do some reproducible repo to this ? like the copy of this project
Author
Owner

@hungds99 commented on GitHub (Aug 2, 2025):

@Kinfe123 Here is my repo: https://github.com/Azentiz/hackathon-project-template

<!-- gh-comment-id:3146167839 --> @hungds99 commented on GitHub (Aug 2, 2025): @Kinfe123 Here is my repo: https://github.com/Azentiz/hackathon-project-template
Author
Owner

@Kinfe123 commented on GitHub (Aug 2, 2025):

the issue you are mapping the generator output schema path with something that does not exists and you are also importing the client where the prisma client is not generated.

easy fix would be - remove the generator path


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

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

and use this import import { PrismaClient } from '@prisma/client'; in your db file.

and then run npx @better-auth/cli generate

Image
<!-- gh-comment-id:3146446707 --> @Kinfe123 commented on GitHub (Aug 2, 2025): the issue you are mapping the generator output schema path with something that does not exists and you are also importing the client where the prisma client is not generated. easy fix would be - remove the generator path ``` generator client { provider = "prisma-client-js" // output = "../src/generated/prisma" remove this } datasource db { provider = "postgresql" url = env("DATABASE_URL") } ``` and use this import `import { PrismaClient } from '@prisma/client';` in your db file. and then run `npx @better-auth/cli generate` <img width="793" height="107" alt="Image" src="https://github.com/user-attachments/assets/31954621-9b64-4b22-970a-4599b04ebecf" />
Author
Owner

@hungds99 commented on GitHub (Aug 2, 2025):

@Kinfe123 it works, thanks for your support

<!-- gh-comment-id:3146566360 --> @hungds99 commented on GitHub (Aug 2, 2025): @Kinfe123 it works, thanks for your support
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#9705