[GH-ISSUE #7649] CLI: getPathAliases ignores jsconfig.json #10865

Closed
opened 2026-04-13 07:13:55 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @jycouet on GitHub (Jan 27, 2026).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/7649

Description

@better-auth/cli generate fails on JSDoc-based projects because getPathAliases() only checks for tsconfig.json, not jsconfig.json. When no tsconfig.json is found, it returns null — so addSvelteKitEnvModules never runs and aliases like $env/dynamic/private, $app/server, $lib/* are never registered for jiti.

TypeScript projects work fine.

Error

Couldn't read your auth config. Error: Cannot find module '$env/dynamic/private'

Reproduction

  1. Create a SvelteKit project with JSDoc: npx sv create
  2. Add better-auth with drizzle
  3. Run npx @better-auth/cli generate --config src/lib/server/auth.js
  4. Fails with Cannot find module '$env/dynamic/private'

I'll provide a PR for this asap 👍

Originally created by @jycouet on GitHub (Jan 27, 2026). Original GitHub issue: https://github.com/better-auth/better-auth/issues/7649 ## Description `@better-auth/cli generate` fails on JSDoc-based projects because `getPathAliases()` only checks for `tsconfig.json`, not `jsconfig.json`. When no `tsconfig.json` is found, it returns `null` — so `addSvelteKitEnvModules` never runs and aliases like `$env/dynamic/private`, `$app/server`, `$lib/*` are never registered for jiti. TypeScript projects work fine. ## Error ``` Couldn't read your auth config. Error: Cannot find module '$env/dynamic/private' ``` ## Reproduction 1. Create a SvelteKit project with JSDoc: `npx sv create` 2. Add better-auth with drizzle 3. Run `npx @better-auth/cli generate --config src/lib/server/auth.js` 4. Fails with `Cannot find module '$env/dynamic/private'` I'll provide a PR for this asap :+1:
GiteaMirror added the locked label 2026-04-13 07:13:55 -05:00
Author
Owner

@better-auth-agent[bot] commented on GitHub (Jan 27, 2026):

It seems that you are encountering an issue where the Better Auth CLI fails on JSDoc-based projects because it only checks for tsconfig.json file and not for jsconfig.json. This results in it returning null, thereby failing to register the necessary aliases for your project.

To troubleshoot this issue, you can try the following steps:

  1. Check for jsconfig.json: Ensure that your jsconfig.json file is correctly set up with the appropriate path aliases.

  2. Modify the CLI Code: If you're comfortable with it, review the getPathAliases function in the Better Auth CLI code. You might want to implement changes to handle jsconfig.json, similar to its handling of tsconfig.json.

  3. Open an Issue or PR: If you are able to fix the issue, consider opening a Pull Request (PR). If you have further questions or need assistance, feel free to tag @bekacru or @ping__ for more direct support from the Better Auth team.

It's great that you're willing to provide a PR! What additional features or fixes do you think would enhance the Better Auth experience further?

If you need more help, tag @better-auth-agent in a comment so I can respond.

Diagram • Discord • GitHub

Diagram Join Star

<!-- gh-comment-id:3808015038 --> @better-auth-agent[bot] commented on GitHub (Jan 27, 2026): It seems that you are encountering an issue where the Better Auth CLI fails on JSDoc-based projects because it only checks for `tsconfig.json` file and not for `jsconfig.json`. This results in it returning `null`, thereby failing to register the necessary aliases for your project. To troubleshoot this issue, you can try the following steps: 1. **Check for jsconfig.json**: Ensure that your `jsconfig.json` file is correctly set up with the appropriate path aliases. 2. **Modify the CLI Code**: If you're comfortable with it, review the `getPathAliases` function in the Better Auth CLI code. You might want to implement changes to handle `jsconfig.json`, similar to its handling of `tsconfig.json`. 3. **Open an Issue or PR**: If you are able to fix the issue, consider opening a Pull Request (PR). If you have further questions or need assistance, feel free to tag @bekacru or @ping__ for more direct support from the Better Auth team. It's great that you're willing to provide a PR! What additional features or fixes do you think would enhance the Better Auth experience further? _If you need more help, tag @better-auth-agent in a comment so I can respond._ <!-- bot:webhook reply v1 --> [Diagram](https://repodiagrams.s3.eu-north-1.amazonaws.com/better-auth_ultra_detailed_interactive.html) • [Discord](https://discord.gg/better-auth) • [GitHub](https://github.com/better-auth/better-auth) [![Diagram](https://img.shields.io/badge/Diagram-2b3137?style=flat-square)](https://repodiagrams.s3.eu-north-1.amazonaws.com/better-auth_ultra_detailed_interactive.html) [![Join](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&style=flat-square)](https://discord.gg/better-auth) [![Star](https://img.shields.io/badge/star-181717?logo=github&logoColor=white&style=flat-square)](https://github.com/better-auth/better-auth)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#10865