[GH-ISSUE #794] better-auth cli not working in monorepo #8436

Closed
opened 2026-04-13 03:30:21 -05:00 by GiteaMirror · 4 comments
Owner

Originally created by @firstaxel on GitHub (Dec 6, 2024).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/794

Is your feature request related to a problem? Please describe.
I am always frustrated when using better-auth in monorepo cause the cli doesn't recognise the auth.ts file which is annoying

Describe the solution you'd like
Please make the CLI support schema generation in monorepos

Originally created by @firstaxel on GitHub (Dec 6, 2024). Original GitHub issue: https://github.com/better-auth/better-auth/issues/794 **Is your feature request related to a problem? Please describe.** I am always frustrated when using better-auth in monorepo cause the cli doesn't recognise the auth.ts file which is annoying **Describe the solution you'd like** Please make the CLI support schema generation in monorepos
GiteaMirror added the locked label 2026-04-13 03:30:21 -05:00
Author
Owner

@firstaxel commented on GitHub (Dec 6, 2024):

@Bekacru

<!-- gh-comment-id:2524529050 --> @firstaxel commented on GitHub (Dec 6, 2024): @Bekacru
Author
Owner

@AmineYagoub commented on GitHub (Dec 10, 2024):

Same problem, I 'm using nx and the migration command never found the configuration file, my workaround is just copy the configuration file to the root of my project and run the migration without --config option.
You don't need to implement all the plugins requirements, just import and use them just to let the cli know what you need.

<!-- gh-comment-id:2531959652 --> @AmineYagoub commented on GitHub (Dec 10, 2024): Same problem, I 'm using nx and the migration command never found the configuration file, my workaround is just copy the configuration file to the root of my project and run the migration without --config option. You don't need to implement all the plugins requirements, just import and use them just to let the cli know what you need.
Author
Owner

@exhaled commented on GitHub (Dec 10, 2024):

Is your feature request related to a problem? Please describe. I am always frustrated when using better-auth in monorepo cause the cli doesn't recognise the auth.ts file which is annoying

Describe the solution you'd like Please make the CLI support schema generation in monorepos

pnpx @better-auth/cli generate --config ./src/auth.ts --output ../db/src/schema/auth.ts

You can specify where config file is located with --config flag as in example above.

<!-- gh-comment-id:2532167369 --> @exhaled commented on GitHub (Dec 10, 2024): > **Is your feature request related to a problem? Please describe.** I am always frustrated when using better-auth in monorepo cause the cli doesn't recognise the auth.ts file which is annoying > > **Describe the solution you'd like** Please make the CLI support schema generation in monorepos `pnpx @better-auth/cli generate --config ./src/auth.ts --output ../db/src/schema/auth.ts` You can specify where config file is located with `--config` flag as in example above.
Author
Owner

@adejam commented on GitHub (Jan 6, 2025):

pnpx @better-auth/cli generate --config ./src/auth.ts --output ../db/src/schema/auth.ts

You can specify where config file is located with --config flag as in example above.

This solution from @exhaled worked for me. However, I needed to add a .env file with DATABASE_URL in the auth package folder to fix the error [Better Auth]: Couldn't read your auth config. Error: Missing DATABASE_URL

<!-- gh-comment-id:2572904088 --> @adejam commented on GitHub (Jan 6, 2025): > `pnpx @better-auth/cli generate --config ./src/auth.ts --output ../db/src/schema/auth.ts` > > You can specify where config file is located with `--config` flag as in example above. This solution from @exhaled worked for me. However, I needed to add a `.env` file with `DATABASE_URL` in the `auth` package folder to fix the error `[Better Auth]: Couldn't read your auth config. Error: Missing DATABASE_URL`
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#8436