[GH-ISSUE #6373] path alias in tsconfig doesn't work #19130

Closed
opened 2026-04-15 17:55:33 -05:00 by GiteaMirror · 15 comments
Owner

Originally created by @ImSingee on GitHub (Nov 28, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/6373

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

Set a path alias in tsconfig.json:

{
  "compilerOptions": {
    "paths": {
      "~*": ["./src/*"]
    }
  }
}

Use ~db to import in better-auth config file:

import { betterAuth } from 'better-auth';
import { drizzleAdapter } from 'better-auth/adapters/drizzle';

import { db } from '~db';

export const auth = betterAuth({
  database: drizzleAdapter(db, {
    provider: 'pg',
  }),
  emailAndPassword: {
    enabled: true,
  },
});

Run npx @better-auth/cli generate and an error occurs:

> npx @better-auth/cli generate --config ./src/auth/server.ts --output ./src/db/auth-schema.ts -y

2025-11-28T06:28:13.088Z ERROR [Better Auth]: Couldn't read your auth config. Error: Cannot find module '~db'
Require stack:
- /project/better-auth-bug-reproduce/src/auth/server.ts
    at Function._resolveFilename (node:internal/modules/cjs/loader:1401:15)
    at Function.resolve (node:internal/modules/helpers:145:19)
    at jitiResolve (/project/better-auth-bug-reproduce/node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/dist/jiti.cjs:1:148703)
    at jitiRequire (/project/better-auth-bug-reproduce/node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/dist/jiti.cjs:1:150290)
    at import (/project/better-auth-bug-reproduce/node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/dist/jiti.cjs:1:158307)
    at /project/better-auth-bug-reproduce/src/auth/server.ts:4:17
    at async Function.import (/project/better-auth-bug-reproduce/node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/dist/jiti.cjs:1:158301)
    at async resolveConfig (file:///project/better-auth-bug-reproduce/node_modules/.pnpm/c12@3.3.2/node_modules/c12/dist/index.mjs:320:20)
    at async loadConfig (file:///project/better-auth-bug-reproduce/node_modules/.pnpm/c12@3.3.2/node_modules/c12/dist/index.mjs:149:22)
    at async getConfig (file:///project/better-auth-bug-reproduce/node_modules/.pnpm/@better-auth+cli@1.4.3_@better-fetch+fetch@1.1.18_@types+better-sqlite3@7.6.13_@types+r_2685a02223f16ac70816b6b7825df188/node_modules/@better-auth/cli/dist/index.mjs:845:23)
    at async Command.generateAction (file:///project/better-auth-bug-reproduce/node_modules/.pnpm/@better-auth+cli@1.4.3_@better-fetch+fetch@1.1.18_@types+better-sqlite3@7.6.13_@types+r_2685a02223f16ac70816b6b7825df188/node_modules/@better-auth/cli/dist/index.mjs:911:17) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/project/better-auth-bug-reproduce/src/auth/server.ts'
  ]
}
 ELIFECYCLE  Command failed with exit code 1.

(Change import { db } from '~db'; to import { db } from '../db'; can make this code snippet work)

I create a dedicated repo for this: https://github.com/ImSingee/better-auth-bug-reproduce

Current vs. Expected behavior

In the earlier version of the better-auth, the path alias works. But now it stops working.

What version of Better Auth are you using?

1.4.3

System info

{
  "system": {
    "platform": "darwin",
    "arch": "arm64",
    "version": "Darwin Kernel Version 25.1.0: Mon Oct 20 19:33:00 PDT 2025; root:xnu-12377.41.6~2/RELEASE_ARM64_T6020",
    "release": "25.1.0",
    "cpuCount": 12,
    "cpuModel": "Apple M2 Max",
    "totalMemory": "96.00 GB",
    "freeMemory": "0.15 GB"
  },
  "node": {
    "version": "v22.15.0",
    "env": "development"
  },
  "packageManager": {
    "name": "npm",
    "version": "10.9.2"
  },
  "frameworks": [
    {
      "name": "react",
      "version": "^19.2.0"
    }
  ],
  "databases": [
    {
      "name": "postgres",
      "version": "^3.4.7"
    },
    {
      "name": "drizzle",
      "version": "^0.44.7"
    }
  ],
  "betterAuth": {
    "version": "^1.4.3",
    "config": null
  }
}

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

Other

Auth config (if applicable)

import { betterAuth } from 'better-auth';
import { drizzleAdapter } from 'better-auth/adapters/drizzle';

import { db } from '~db';

export const auth = betterAuth({
  database: drizzleAdapter(db, {
    provider: 'pg',
  }),
  emailAndPassword: {
    enabled: true,
  },
});

Additional context

No response

Originally created by @ImSingee on GitHub (Nov 28, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/6373 ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce Set a path alias in `tsconfig.json`: ``` { "compilerOptions": { "paths": { "~*": ["./src/*"] } } } ``` Use `~db` to import in better-auth config file: ``` import { betterAuth } from 'better-auth'; import { drizzleAdapter } from 'better-auth/adapters/drizzle'; import { db } from '~db'; export const auth = betterAuth({ database: drizzleAdapter(db, { provider: 'pg', }), emailAndPassword: { enabled: true, }, }); ``` Run `npx @better-auth/cli generate` and an error occurs: ``` > npx @better-auth/cli generate --config ./src/auth/server.ts --output ./src/db/auth-schema.ts -y 2025-11-28T06:28:13.088Z ERROR [Better Auth]: Couldn't read your auth config. Error: Cannot find module '~db' Require stack: - /project/better-auth-bug-reproduce/src/auth/server.ts at Function._resolveFilename (node:internal/modules/cjs/loader:1401:15) at Function.resolve (node:internal/modules/helpers:145:19) at jitiResolve (/project/better-auth-bug-reproduce/node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/dist/jiti.cjs:1:148703) at jitiRequire (/project/better-auth-bug-reproduce/node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/dist/jiti.cjs:1:150290) at import (/project/better-auth-bug-reproduce/node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/dist/jiti.cjs:1:158307) at /project/better-auth-bug-reproduce/src/auth/server.ts:4:17 at async Function.import (/project/better-auth-bug-reproduce/node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/dist/jiti.cjs:1:158301) at async resolveConfig (file:///project/better-auth-bug-reproduce/node_modules/.pnpm/c12@3.3.2/node_modules/c12/dist/index.mjs:320:20) at async loadConfig (file:///project/better-auth-bug-reproduce/node_modules/.pnpm/c12@3.3.2/node_modules/c12/dist/index.mjs:149:22) at async getConfig (file:///project/better-auth-bug-reproduce/node_modules/.pnpm/@better-auth+cli@1.4.3_@better-fetch+fetch@1.1.18_@types+better-sqlite3@7.6.13_@types+r_2685a02223f16ac70816b6b7825df188/node_modules/@better-auth/cli/dist/index.mjs:845:23) at async Command.generateAction (file:///project/better-auth-bug-reproduce/node_modules/.pnpm/@better-auth+cli@1.4.3_@better-fetch+fetch@1.1.18_@types+better-sqlite3@7.6.13_@types+r_2685a02223f16ac70816b6b7825df188/node_modules/@better-auth/cli/dist/index.mjs:911:17) { code: 'MODULE_NOT_FOUND', requireStack: [ '/project/better-auth-bug-reproduce/src/auth/server.ts' ] }  ELIFECYCLE  Command failed with exit code 1. ``` (Change `import { db } from '~db';` to `import { db } from '../db';` can make this code snippet work) I create a dedicated repo for this: https://github.com/ImSingee/better-auth-bug-reproduce ### Current vs. Expected behavior In the earlier version of the better-auth, the path alias works. But now it stops working. ### What version of Better Auth are you using? 1.4.3 ### System info ```bash { "system": { "platform": "darwin", "arch": "arm64", "version": "Darwin Kernel Version 25.1.0: Mon Oct 20 19:33:00 PDT 2025; root:xnu-12377.41.6~2/RELEASE_ARM64_T6020", "release": "25.1.0", "cpuCount": 12, "cpuModel": "Apple M2 Max", "totalMemory": "96.00 GB", "freeMemory": "0.15 GB" }, "node": { "version": "v22.15.0", "env": "development" }, "packageManager": { "name": "npm", "version": "10.9.2" }, "frameworks": [ { "name": "react", "version": "^19.2.0" } ], "databases": [ { "name": "postgres", "version": "^3.4.7" }, { "name": "drizzle", "version": "^0.44.7" } ], "betterAuth": { "version": "^1.4.3", "config": null } } ``` ### Which area(s) are affected? (Select all that apply) Other ### Auth config (if applicable) ```typescript import { betterAuth } from 'better-auth'; import { drizzleAdapter } from 'better-auth/adapters/drizzle'; import { db } from '~db'; export const auth = betterAuth({ database: drizzleAdapter(db, { provider: 'pg', }), emailAndPassword: { enabled: true, }, }); ``` ### Additional context _No response_
GiteaMirror added the lockedbug labels 2026-04-15 17:55:33 -05:00
Author
Owner

@better-auth-agent[bot] commented on GitHub (Nov 28, 2025):

It looks like the new Better Auth CLI isn’t resolving the TypeScript path alias correctly. This issue appears because the CLI uses its own module resolution logic that may not currently support the alias mappings from your tsconfig. As a workaround, using a relative path (as you discovered) should resolve the error. We’re investigating how to better support path aliases in future releases. Have you tried using a module aliasing package or adjusting the runtime module resolution settings as an alternative solution? Tag @better-auth-agent if you would like an answer from the Agent.

DiagramDiscordGitHub

Diagram Join Star

<!-- gh-comment-id:3588081564 --> @better-auth-agent[bot] commented on GitHub (Nov 28, 2025): It looks like the new Better Auth CLI isn’t resolving the TypeScript path alias correctly. This issue appears because the CLI uses its own module resolution logic that may not currently support the alias mappings from your tsconfig. As a workaround, using a relative path (as you discovered) should resolve the error. We’re investigating how to better support path aliases in future releases. Have you tried using a module aliasing package or adjusting the runtime module resolution settings as an alternative solution? Tag @better-auth-agent if you would like an answer from the Agent. <!-- 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)
Author
Owner

@ping-maxwell commented on GitHub (Nov 28, 2025):

TLDR: Path Aliases are not actually a proper typescript feature, rather it relies on a bundler under the hood to convert it to a real path.

Path aliases require a bundler or module loader to convert them to real file paths, but jiti is a lightweight runtime TypeScript loader that only transpiles code - it doesn't resolve aliases. So when Better-Auth CLI uses jiti to load config files, aliased imports fail because there's no bundler in the pipeline to map them to actual paths.

Please follow this issue for more information, if this is eventually supported in jiti then it can be supported in Better-Auth too!
https://github.com/unjs/jiti/issues/166

<!-- gh-comment-id:3589236104 --> @ping-maxwell commented on GitHub (Nov 28, 2025): TLDR: Path Aliases are not actually a *proper* typescript feature, rather it relies on a bundler under the hood to convert it to a real path. Path aliases require a bundler or module loader to convert them to real file paths, but `jiti` is a lightweight runtime TypeScript loader that only transpiles code - it doesn't resolve aliases. So when Better-Auth CLI uses `jiti` to load config files, aliased imports fail because there's no bundler in the pipeline to map them to actual paths. Please follow this issue for more information, if this is eventually supported in `jiti` then it can be supported in Better-Auth too! https://github.com/unjs/jiti/issues/166
Author
Owner

@ping-maxwell commented on GitHub (Nov 28, 2025):

(I'll keep this open for now in case it's supported in jiti some day)

<!-- gh-comment-id:3589243774 --> @ping-maxwell commented on GitHub (Nov 28, 2025): (I'll keep this open for now in case it's supported in `jiti` some day)
Author
Owner

@himself65 commented on GitHub (Dec 1, 2025):

I remember we have a PR to use vite to load path, I think that would also fix this issue

Related: https://github.com/better-auth/better-auth/pull/5917

<!-- gh-comment-id:3598848231 --> @himself65 commented on GitHub (Dec 1, 2025): I remember we have a PR to use vite to load path, I think that would also fix this issue Related: https://github.com/better-auth/better-auth/pull/5917
Author
Owner

@shreyassanthu77 commented on GitHub (Dec 2, 2025):

My pr only works if the project already is a vite project though

edit: one way we can fix this is by replacing jiti with esbuild and a couple esbuild plugins (this can also potentially help better support pure deno projects without mode modules dir) or bundle in vite with the cli so we can fallback to that with a default vite config if the user doesn't have vite installed. But both of these options are temporary fixes for this problem imo

<!-- gh-comment-id:3601531217 --> @shreyassanthu77 commented on GitHub (Dec 2, 2025): My pr only works if the project already is a vite project though edit: one way we can fix this is by replacing jiti with esbuild and a couple esbuild plugins (this can also potentially help better support pure deno projects without mode modules dir) or bundle in vite with the cli so we can fallback to that with a default vite config if the user doesn't have vite installed. But both of these options are temporary fixes for this problem imo
Author
Owner

@bojanbass commented on GitHub (Dec 4, 2025):

I wanted to use ts path aliases, but noticed that if a tsconfig extends from another base tsconfig, where aliases are defined, it doesn't read them correctly. It is a monorepo setup (NX) which looks like is not covered in this cli.

<!-- gh-comment-id:3614618365 --> @bojanbass commented on GitHub (Dec 4, 2025): I wanted to use ts path aliases, but noticed that if a tsconfig extends from another base tsconfig, where aliases are defined, it doesn't read them correctly. It is a monorepo setup (NX) which looks like is not covered in this cli.
Author
Owner

@shreyassanthu77 commented on GitHub (Dec 5, 2025):

I wanted to use ts path aliases, but noticed that if a tsconfig extends from another base tsconfig, where aliases are defined, it doesn't read them correctly. It is a monorepo setup (NX) which looks like is not covered in this cli.

can you try one thing real quick

  • create a temporary typescript file with a monorepos import from an aliased package (console log it so it doesn't get tree shaken)
  • try building that file with rolldown
npx rolldown -d dist test.ts

and then tell me if that works without any errors

<!-- gh-comment-id:3614866324 --> @shreyassanthu77 commented on GitHub (Dec 5, 2025): > I wanted to use ts path aliases, but noticed that if a tsconfig extends from another base tsconfig, where aliases are defined, it doesn't read them correctly. It is a monorepo setup (NX) which looks like is not covered in this cli. can you try one thing real quick - create a temporary typescript file with a monorepos import from an aliased package (console log it so it doesn't get tree shaken) - try building that file with rolldown ```sh npx rolldown -d dist test.ts ``` and then tell me if that works without any errors
Author
Owner

@bojanbass commented on GitHub (Dec 5, 2025):

I wanted to use ts path aliases, but noticed that if a tsconfig extends from another base tsconfig, where aliases are defined, it doesn't read them correctly. It is a monorepo setup (NX) which looks like is not covered in this cli.

can you try one thing real quick

  • create a temporary typescript file with a monorepos import from an aliased package (console log it so it doesn't get tree shaken)
  • try building that file with rolldown

npx rolldown -d dist test.ts
and then tell me if that works without any errors

I've tried it and it doesn't work correctly, even though the cli command finished succesfully.

❯ npx rolldown -d dist db/auth.config.ts
[UNRESOLVED_IMPORT] Warning: Could not resolve '@mycompany/mydomain/util-auth-config' in db/auth.config.ts
   ╭─[ db/auth.config.ts:5:29 ]
   │
 5 │ import { authOptions } from '@mycompany/mydomain/util-auth-config';
   │                             ──────────────────┬─────────────────
   │                                               ╰─────────────────── Module not found, treating it as an external dependency
───╯

<DIR>/auth.config.js  chunk │ size: 0.14 kB

✔ rolldown v1.0.0-beta.53 Finished in 7.09 ms
<!-- gh-comment-id:3618129307 --> @bojanbass commented on GitHub (Dec 5, 2025): > > I wanted to use ts path aliases, but noticed that if a tsconfig extends from another base tsconfig, where aliases are defined, it doesn't read them correctly. It is a monorepo setup (NX) which looks like is not covered in this cli. > > can you try one thing real quick > > * create a temporary typescript file with a monorepos import from an aliased package (console log it so it doesn't get tree shaken) > * try building that file with rolldown > > npx rolldown -d dist test.ts > and then tell me if that works without any errors I've tried it and it doesn't work correctly, even though the cli command finished succesfully. ``` ❯ npx rolldown -d dist db/auth.config.ts [UNRESOLVED_IMPORT] Warning: Could not resolve '@mycompany/mydomain/util-auth-config' in db/auth.config.ts ╭─[ db/auth.config.ts:5:29 ] │ 5 │ import { authOptions } from '@mycompany/mydomain/util-auth-config'; │ ──────────────────┬───────────────── │ ╰─────────────────── Module not found, treating it as an external dependency ───╯ <DIR>/auth.config.js chunk │ size: 0.14 kB ✔ rolldown v1.0.0-beta.53 Finished in 7.09 ms ```
Author
Owner

@bojanbass commented on GitHub (Dec 5, 2025):

One thing to add, when running such scripts which use local ts aliases with ts-node, I always have to use it this way:

ts-node --project tools/tsconfig.tools.json --require tsconfig-paths/register myfile.ts
<!-- gh-comment-id:3618134575 --> @bojanbass commented on GitHub (Dec 5, 2025): One thing to add, when running such scripts which use local ts aliases with `ts-node`, I always have to use it this way: ``` ts-node --project tools/tsconfig.tools.json --require tsconfig-paths/register myfile.ts ```
Author
Owner

@shreyassanthu77 commented on GitHub (Dec 6, 2025):

I wanted to use ts path aliases, but noticed that if a tsconfig extends from another base tsconfig, where aliases are defined, it doesn't read them correctly. It is a monorepo setup (NX) which looks like is not covered in this cli.

can you try one thing real quick

  • create a temporary typescript file with a monorepos import from an aliased package (console log it so it doesn't get tree shaken)
  • try building that file with rolldown

npx rolldown -d dist test.ts
and then tell me if that works without any errors

I've tried it and it doesn't work correctly, even though the cli command finished succesfully.

❯ npx rolldown -d dist db/auth.config.ts
[UNRESOLVED_IMPORT] Warning: Could not resolve '@mycompany/mydomain/util-auth-config' in db/auth.config.ts
   ╭─[ db/auth.config.ts:5:29 ]
   │
 5 │ import { authOptions } from '@mycompany/mydomain/util-auth-config';
   │                             ──────────────────┬─────────────────
   │                                               ╰─────────────────── Module not found, treating it as an external dependency
───╯

<DIR>/auth.config.js  chunk │ size: 0.14 kB

✔ rolldown v1.0.0-beta.53 Finished in 7.09 ms

oh looks like it doesn't even load tsconfig by default. I should've checked that mb

can you try creating a rolldown.config.js with export default { tsconfig: "<path to tsconfig>" } and then try running rolldown again but with a flag -c rolldown.config.js

<!-- gh-comment-id:3619952428 --> @shreyassanthu77 commented on GitHub (Dec 6, 2025): > > > I wanted to use ts path aliases, but noticed that if a tsconfig extends from another base tsconfig, where aliases are defined, it doesn't read them correctly. It is a monorepo setup (NX) which looks like is not covered in this cli. > > > > can you try one thing real quick > > > > * create a temporary typescript file with a monorepos import from an aliased package (console log it so it doesn't get tree shaken) > > * try building that file with rolldown > > > > npx rolldown -d dist test.ts > > and then tell me if that works without any errors > > I've tried it and it doesn't work correctly, even though the cli command finished succesfully. > ``` > ❯ npx rolldown -d dist db/auth.config.ts > [UNRESOLVED_IMPORT] Warning: Could not resolve '@mycompany/mydomain/util-auth-config' in db/auth.config.ts > ╭─[ db/auth.config.ts:5:29 ] > │ > 5 │ import { authOptions } from '@mycompany/mydomain/util-auth-config'; > │ ──────────────────┬───────────────── > │ ╰─────────────────── Module not found, treating it as an external dependency > ───╯ > > <DIR>/auth.config.js chunk │ size: 0.14 kB > > ✔ rolldown v1.0.0-beta.53 Finished in 7.09 ms > ``` oh looks like it doesn't even load tsconfig by default. I should've checked that mb can you try creating a rolldown.config.js with export default { tsconfig: "`<path to tsconfig>`" } and then try running rolldown again but with a flag -c rolldown.config.js
Author
Owner

@dosubot[bot] commented on GitHub (Mar 7, 2026):

Hi, @ImSingee. I'm Dosu, and I'm helping the better-auth team manage their backlog and am marking this issue as stale.

Issue Summary:

  • You reported that TypeScript path aliases in tsconfig.json are not resolved by the Better Auth CLI generate command, causing module not found errors.
  • The CLI uses the jiti loader, which transpiles but does not resolve path aliases, leading to this limitation.
  • Workarounds suggested include using relative paths or module aliasing packages.
  • Comments indicate that proper alias support depends on bundler integration, with potential fixes involving replacing jiti with esbuild or bundling with vite.
  • The issue remains open awaiting upstream support in jiti, and monorepo setups with extended tsconfigs also experience unresolved alias problems.

Next Steps:

  • Please let me know if this issue is still relevant with the latest version of better-auth by commenting here to keep the discussion open.
  • Otherwise, I will automatically close this issue in 7 days.

Thank you for your understanding and contribution!

<!-- gh-comment-id:4016818755 --> @dosubot[bot] commented on GitHub (Mar 7, 2026): Hi, @ImSingee. I'm [Dosu](https://dosu.dev), and I'm helping the better-auth team manage their backlog and am marking this issue as stale. **Issue Summary:** - You reported that TypeScript path aliases in tsconfig.json are not resolved by the Better Auth CLI generate command, causing module not found errors. - The CLI uses the jiti loader, which transpiles but does not resolve path aliases, leading to this limitation. - Workarounds suggested include using relative paths or module aliasing packages. - Comments indicate that proper alias support depends on bundler integration, with potential fixes involving replacing jiti with esbuild or bundling with vite. - The issue remains open awaiting upstream support in jiti, and monorepo setups with extended tsconfigs also experience unresolved alias problems. **Next Steps:** - Please let me know if this issue is still relevant with the latest version of better-auth by commenting here to keep the discussion open. - Otherwise, I will automatically close this issue in 7 days. Thank you for your understanding and contribution!
Author
Owner

@DarthGigi commented on GitHub (Mar 9, 2026):

This issue is not stale

<!-- gh-comment-id:4025219140 --> @DarthGigi commented on GitHub (Mar 9, 2026): This issue is not stale
Author
Owner

@shreyassanthu77 commented on GitHub (Mar 9, 2026):

@DarthGigi if you have this issue can you try creating a vite config in the project with the https://github.com/aleclarson/vite-tsconfig-paths plugin and try running the cli with my pr (#5917) and see if that works please

edit: lol nvm looks like they're working on it already

<!-- gh-comment-id:4025322339 --> @shreyassanthu77 commented on GitHub (Mar 9, 2026): @DarthGigi if you have this issue can you try creating a vite config in the project with the https://github.com/aleclarson/vite-tsconfig-paths plugin and try running the cli with my pr (#5917) and see if that works please edit: lol nvm looks like they're working on it already
Author
Owner

@DarthGigi commented on GitHub (Mar 13, 2026):

Coming back to this after finally getting around to trying, I'm getting the following error:

pnpx auth generate
[#better-auth]: Couldn't read your auth config. Error: Cannot find module '$app/environment'

Is #8520 supposed to fix this issue or is this a different issue?

Edit: It looks like no aliases work when in a monorepo

~/Projects/ProjectName/subproject
pnpx auth migrate
[#better-auth]: Couldn't read your auth config. Error: Cannot find module '/Users/gigi/Projects/ProjectName/src/lib/server/email-service'

/Users/gigi/Projects/ProjectName/src/lib/server/email-service should be /Users/gigi/Projects/ProjectName/subproject/src/lib/server/email-service

<!-- gh-comment-id:4056158210 --> @DarthGigi commented on GitHub (Mar 13, 2026): Coming back to this after finally getting around to trying, I'm getting the following error: ``` pnpx auth generate [#better-auth]: Couldn't read your auth config. Error: Cannot find module '$app/environment' ``` Is #8520 supposed to fix this issue or is this a different issue? Edit: It looks like no aliases work when in a monorepo ``` ~/Projects/ProjectName/subproject pnpx auth migrate [#better-auth]: Couldn't read your auth config. Error: Cannot find module '/Users/gigi/Projects/ProjectName/src/lib/server/email-service' ``` `/Users/gigi/Projects/ProjectName/src/lib/server/email-service` should be `/Users/gigi/Projects/ProjectName/subproject/src/lib/server/email-service`
Author
Owner

@github-actions[bot] commented on GitHub (Mar 31, 2026):

This issue has been locked as it was closed more than 7 days ago. If you're experiencing a similar problem or you have additional context, please open a new issue and reference this one.

<!-- gh-comment-id:4165921185 --> @github-actions[bot] commented on GitHub (Mar 31, 2026): This issue has been locked as it was closed more than 7 days ago. If you're experiencing a similar problem or you have additional context, please open a new issue and reference this one.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#19130