TS errors with Stripe plugin when using type:module #1729

Closed
opened 2026-03-13 08:59:05 -05:00 by GiteaMirror · 11 comments
Owner

Originally created by @cesconix on GitHub (Aug 17, 2025).

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

When package.json includes "type": "module", the Stripe plugin throws TypeScript errors. Removing this field from package.json resolves the TS errors.

package.json (causing issues)

{
  "name": "issue",
  "type": "module",
  "packageManager": "pnpm@10.7.0",
  "dependencies": {
    "@better-auth/stripe": "^1.3.6",
    "@types/node": "^22",
    "better-auth": "^1.3.5",
    "pg": "^8.16.3",
    "stripe": "^18.0.0"
  }
}

tsconfig.json

{
  "$schema": "https://json.schemastore.org/tsconfig",
  "compilerOptions": {
    "target": "esnext",
    "module": "nodenext",
    "strict": true,
    "skipLibCheck": true,
    "types": ["node"],
    "outDir": "./dist"
  },
  "exclude": ["node_modules"]
}

src/auth.ts

import { betterAuth } from "better-auth";
import { organization } from "better-auth/plugins";
import { stripe } from "@better-auth/stripe";

import { Pool } from "pg";
import Stripe from "stripe";

const stripeClient = new Stripe("API_KEY", {
  apiVersion: "2025-07-30.basil",
  typescript: true,
});

export const auth = betterAuth({
  database: new Pool({
    connectionString: "CONNECTION_STRING",
  }),
  plugins: [
    organization(),
    stripe({
      stripeClient,
      stripeWebhookSecret: "asc",
      createCustomerOnSignUp: true,
    }),
  ],
});

Environment

  • Node.js: v22
  • Package Manager: pnpm 10.7.0
  • better-auth: ^1.3.5
  • @better-auth/stripe: ^1.3.5
  • stripe: ^18.0.0

Current Workaround

Remove "type": "module" from package.json.

Current vs. Expected behavior

TypeScript compilation fails when "type": "module" is present in package.json. The Stripe plugin should work correctly with ES modules configuration.

What version of Better Auth are you using?

1.3.5

System info

System:
  OS: macOS 15.5
  CPU: (10) arm64 Apple M2 Pro
  Memory: 122.50 MB / 16.00 GB
  Shell: 5.9 - /bin/zsh
Browsers:
  Chrome: 139.0.7258.128
  Safari: 18.5

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

Types

Auth config (if applicable)

import { betterAuth } from "better-auth";
import { organization } from "better-auth/plugins";
import { stripe } from "@better-auth/stripe";

import { Pool } from "pg";
import Stripe from "stripe";

const stripeClient = new Stripe("API_KEY", {
  apiVersion: "2025-07-30.basil",
  typescript: true,
});

export const auth = betterAuth({
  database: new Pool({
    connectionString: "CONNECTION_STRING",
  }),
  plugins: [
    organization(),
    stripe({
      stripeClient,
      stripeWebhookSecret: "asc",
      createCustomerOnSignUp: true,
    }),
  ],
});

Additional context

All other better-auth functionality works correctly with ES modules.

Originally created by @cesconix on GitHub (Aug 17, 2025). ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce When `package.json` includes `"type": "module"`, the Stripe plugin throws TypeScript errors. Removing this field from package.json resolves the TS errors. ### package.json (causing issues) ```json { "name": "issue", "type": "module", "packageManager": "pnpm@10.7.0", "dependencies": { "@better-auth/stripe": "^1.3.6", "@types/node": "^22", "better-auth": "^1.3.5", "pg": "^8.16.3", "stripe": "^18.0.0" } } ``` ### tsconfig.json ```json { "$schema": "https://json.schemastore.org/tsconfig", "compilerOptions": { "target": "esnext", "module": "nodenext", "strict": true, "skipLibCheck": true, "types": ["node"], "outDir": "./dist" }, "exclude": ["node_modules"] } ``` ### src/auth.ts ```ts import { betterAuth } from "better-auth"; import { organization } from "better-auth/plugins"; import { stripe } from "@better-auth/stripe"; import { Pool } from "pg"; import Stripe from "stripe"; const stripeClient = new Stripe("API_KEY", { apiVersion: "2025-07-30.basil", typescript: true, }); export const auth = betterAuth({ database: new Pool({ connectionString: "CONNECTION_STRING", }), plugins: [ organization(), stripe({ stripeClient, stripeWebhookSecret: "asc", createCustomerOnSignUp: true, }), ], }); ``` ### Environment - **Node.js**: v22 - **Package Manager**: pnpm 10.7.0 - **better-auth**: ^1.3.5 - **@better-auth/stripe**: ^1.3.5 - **stripe**: ^18.0.0 ### Current Workaround Remove `"type": "module"` from package.json. ### Current vs. Expected behavior TypeScript compilation fails when `"type": "module"` is present in package.json. The Stripe plugin should work correctly with ES modules configuration. ### What version of Better Auth are you using? 1.3.5 ### System info ```bash System: OS: macOS 15.5 CPU: (10) arm64 Apple M2 Pro Memory: 122.50 MB / 16.00 GB Shell: 5.9 - /bin/zsh Browsers: Chrome: 139.0.7258.128 Safari: 18.5 ``` ### Which area(s) are affected? (Select all that apply) Types ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth"; import { organization } from "better-auth/plugins"; import { stripe } from "@better-auth/stripe"; import { Pool } from "pg"; import Stripe from "stripe"; const stripeClient = new Stripe("API_KEY", { apiVersion: "2025-07-30.basil", typescript: true, }); export const auth = betterAuth({ database: new Pool({ connectionString: "CONNECTION_STRING", }), plugins: [ organization(), stripe({ stripeClient, stripeWebhookSecret: "asc", createCustomerOnSignUp: true, }), ], }); ``` ### Additional context All other better-auth functionality works correctly with ES modules.
GiteaMirror added the plugin label 2026-03-13 08:59:05 -05:00
Author
Owner

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

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

This is a known issue: when using "type": "module" in your package.json, the Stripe plugin for Better Auth can trigger TypeScript errors, most commonly "The inferred type of this node exceeds the maximum length the compiler will serialize. An explicit type annotation is needed" or similar type inference problems. This happens due to complex type inference in plugin composition and how TypeScript resolves types in ESM projects with dual module packages like @better-auth/stripe [source].

Workarounds and recommendations:

  • Add explicit type annotations to your auth export or any plugin configuration that triggers the error. For example:

    export const auth: ReturnType<typeof betterAuth> = betterAuth({ ... });
    
  • If you hit type errors in plugin hooks (like onCustomerCreate), manually cast the user object to include any custom fields you expect, e.g.,

    onCustomerCreate: async ({ user, ...rest }, request) => {
      const typedUser = user as typeof user & { first_name: string };
      // use typedUser.first_name
    }
    
  • If you see errors about optional or undefined fields in plugin schemas, you may need to add | undefined to the relevant types or use // @ts-ignore as a temporary workaround [source].

  • Make sure all your better-auth packages are on the same version to avoid type incompatibility between different versions in node_modules [source].

The Stripe plugin is intended to work with ES modules and TypeScript, and its package.json is set up for dual ESM/CJS support [source]. However, TypeScript's type inference and module resolution can still cause issues in ESM projects, especially with complex plugin setups.

If you continue to see errors, sharing the exact TypeScript error message will help pinpoint the best workaround.

To reply, just mention @dosu.


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

@dosubot[bot] commented on GitHub (Aug 17, 2025): <!-- Greeting --> Hi @cesconix! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the better-auth team. <!-- Answer --> This is a known issue: when using `"type": "module"` in your `package.json`, the Stripe plugin for Better Auth can trigger TypeScript errors, most commonly `"The inferred type of this node exceeds the maximum length the compiler will serialize. An explicit type annotation is needed"` or similar type inference problems. This happens due to complex type inference in plugin composition and how TypeScript resolves types in ESM projects with dual module packages like `@better-auth/stripe` [[source](https://github.com/better-auth/better-auth/issues/3103)]. **Workarounds and recommendations:** - Add explicit type annotations to your `auth` export or any plugin configuration that triggers the error. For example: ```ts export const auth: ReturnType<typeof betterAuth> = betterAuth({ ... }); ``` - If you hit type errors in plugin hooks (like `onCustomerCreate`), manually cast the user object to include any custom fields you expect, e.g., ```ts onCustomerCreate: async ({ user, ...rest }, request) => { const typedUser = user as typeof user & { first_name: string }; // use typedUser.first_name } ``` - If you see errors about optional or undefined fields in plugin schemas, you may need to add `| undefined` to the relevant types or use `// @ts-ignore` as a temporary workaround [[source](https://github.com/better-auth/better-auth/issues/3570#issuecomment-3115816708)]. - Make sure all your `better-auth` packages are on the same version to avoid type incompatibility between different versions in `node_modules` [[source](https://github.com/better-auth/better-auth/issues/2758#issuecomment-3100454454)]. The Stripe plugin is intended to work with ES modules and TypeScript, and its package.json is set up for dual ESM/CJS support [[source](https://github.com/better-auth/better-auth/blob/efa60af1c2d45a735ed397171bfca513b7e202ca/packages/stripe/package.json)]. However, TypeScript's type inference and module resolution can still cause issues in ESM projects, especially with complex plugin setups. If you continue to see errors, sharing the exact TypeScript error message will help pinpoint the best workaround. <!-- 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/e6d05f7e-63c3-449d-8eac-a66c5fabc010?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/e6d05f7e-63c3-449d-8eac-a66c5fabc010?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/e6d05f7e-63c3-449d-8eac-a66c5fabc010?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/e6d05f7e-63c3-449d-8eac-a66c5fabc010?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/e6d05f7e-63c3-449d-8eac-a66c5fabc010?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/e6d05f7e-63c3-449d-8eac-a66c5fabc010?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/e6d05f7e-63c3-449d-8eac-a66c5fabc010?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/4054)
Author
Owner

@cesconix commented on GitHub (Aug 17, 2025):

I added ReturnType<typeof betterAuth> but the TS error persists:

Image
src/auth.ts(19,5): error TS2322: Type '{ id: "stripe"; endpoints: { stripeWebhook: { <AsResponse extends boolean = false, ReturnHeaders extends boolean = false>(inputCtx_0?: ({ body?: undefined; } & { method?: "POST" | undefined; } & { query?: Record<string, any> | undefined; } & ... 4 more ... & { ...; }) | undefined): Promise<...>; options: { ...; } & ...' is not assignable to type 'BetterAuthPlugin'.
  Types of property 'init' are incompatible.
    Type '(ctx: AuthContext) => { options: { databaseHooks: { user: { create: { after(user: { id: string; email: string; emailVerified: boolean; name: string; createdAt: Date; updatedAt: Date; image?: string | ... 1 more ... | undefined; } & Record<...>, ctx: GenericEndpointContext | undefined): Promise<...>; }; }; }; }; }' is not assignable to type '(ctx: AuthContext) => void | { context?: { password?: { hash?: ((password: string) => Promise<string>) | undefined; verify?: ((data: { password: string; hash: string; }) => Promise<...>) | undefined; config?: { ...; } | undefined; checkPassword?: ((userId: string, c: GenericEndpointContext) => Promise<...>) | undefi...'.
      Types of parameters 'ctx' and 'ctx' are incompatible.
        Type 'import("/Users/cesconix/workspace/issue/node_modules/.pnpm/better-auth@1.3.5_zod@4.0.17/node_modules/better-auth/dist/shared/better-auth.CpTWU-gb", { with: { "resolution-mode": "import" } }).p' is not assignable to type 'import("/Users/cesconix/workspace/issue/node_modules/.pnpm/better-auth@1.3.5_zod@4.0.17/node_modules/better-auth/dist/shared/better-auth.DSYK4jT-").p'.
          The types of 'options.socialProviders' are incompatible between these types.
            Type 'import("/Users/cesconix/workspace/issue/node_modules/.pnpm/better-auth@1.3.5_zod@4.0.17/node_modules/better-auth/dist/shared/better-auth.B-pjewPT", { with: { "resolution-mode": "import" } }).S | undefined' is not assignable to type 'import("/Users/cesconix/workspace/issue/node_modules/.pnpm/better-auth@1.3.5_zod@4.0.17/node_modules/better-auth/dist/shared/better-auth.DSvLrleU").S | undefined'.
              Type 'import("/Users/cesconix/workspace/issue/node_modules/.pnpm/better-auth@1.3.5_zod@4.0.17/node_modules/better-auth/dist/shared/better-auth.B-pjewPT", { with: { "resolution-mode": "import" } }).S' is not assignable to type 'import("/Users/cesconix/workspace/issue/node_modules/.pnpm/better-auth@1.3.5_zod@4.0.17/node_modules/better-auth/dist/shared/better-auth.DSvLrleU").S'.
                Types of property 'vk' are incompatible.
                  Type 'import("/Users/cesconix/workspace/issue/node_modules/.pnpm/better-auth@1.3.5_zod@4.0.17/node_modules/better-auth/dist/shared/better-auth.BDR52Rf2", { with: { "resolution-mode": "import" } }).a<import("/Users/cesconix/workspace/issue/node_modules/.pnpm/better-auth@1.3.5_zod@4.0.17/node_modules/better-auth/dist/shared...' is not assignable to type 'import("/Users/cesconix/workspace/issue/node_modules/.pnpm/better-auth@1.3.5_zod@4.0.17/node_modules/better-auth/dist/shared/better-auth.BDR52Rf2").a<import("/Users/cesconix/workspace/issue/node_modules/.pnpm/better-auth@1.3.5_zod@4.0.17/node_modules/better-auth/dist/shared/better-auth.DSvLrleU").ad & { enabled?: bo...'.
                    Type 'import("/Users/cesconix/workspace/issue/node_modules/.pnpm/better-auth@1.3.5_zod@4.0.17/node_modules/better-auth/dist/shared/better-auth.BDR52Rf2", { with: { "resolution-mode": "import" } }).a<import("/Users/cesconix/workspace/issue/node_modules/.pnpm/better-auth@1.3.5_zod@4.0.17/node_modules/better-auth/dist/shared...' is not assignable to type 'import("/Users/cesconix/workspace/issue/node_modules/.pnpm/better-auth@1.3.5_zod@4.0.17/node_modules/better-auth/dist/shared/better-auth.BDR52Rf2").a<import("/Users/cesconix/workspace/issue/node_modules/.pnpm/better-auth@1.3.5_zod@4.0.17/node_modules/better-auth/dist/shared/better-auth.DSvLrleU").ad & { enabled?: bo...'.
                      Types of property 'lang_id' are incompatible.
                        Type 'import("/Users/cesconix/workspace/issue/node_modules/.pnpm/better-auth@1.3.5_zod@4.0.17/node_modules/better-auth/dist/shared/better-auth.B-pjewPT", { with: { "resolution-mode": "import" } }).ac | undefined' is not assignable to type 'import("/Users/cesconix/workspace/issue/node_modules/.pnpm/better-auth@1.3.5_zod@4.0.17/node_modules/better-auth/dist/shared/better-auth.DSvLrleU").ac | undefined'.
                          Type 'LANG.RUS' is not assignable to type 'LANG | undefined'.
@cesconix commented on GitHub (Aug 17, 2025): I added `ReturnType<typeof betterAuth>` but the TS error persists: <img width="1114" height="970" alt="Image" src="https://github.com/user-attachments/assets/665555ff-fb77-481f-8fae-82c9d5e91f87" /> ``` src/auth.ts(19,5): error TS2322: Type '{ id: "stripe"; endpoints: { stripeWebhook: { <AsResponse extends boolean = false, ReturnHeaders extends boolean = false>(inputCtx_0?: ({ body?: undefined; } & { method?: "POST" | undefined; } & { query?: Record<string, any> | undefined; } & ... 4 more ... & { ...; }) | undefined): Promise<...>; options: { ...; } & ...' is not assignable to type 'BetterAuthPlugin'. Types of property 'init' are incompatible. Type '(ctx: AuthContext) => { options: { databaseHooks: { user: { create: { after(user: { id: string; email: string; emailVerified: boolean; name: string; createdAt: Date; updatedAt: Date; image?: string | ... 1 more ... | undefined; } & Record<...>, ctx: GenericEndpointContext | undefined): Promise<...>; }; }; }; }; }' is not assignable to type '(ctx: AuthContext) => void | { context?: { password?: { hash?: ((password: string) => Promise<string>) | undefined; verify?: ((data: { password: string; hash: string; }) => Promise<...>) | undefined; config?: { ...; } | undefined; checkPassword?: ((userId: string, c: GenericEndpointContext) => Promise<...>) | undefi...'. Types of parameters 'ctx' and 'ctx' are incompatible. Type 'import("/Users/cesconix/workspace/issue/node_modules/.pnpm/better-auth@1.3.5_zod@4.0.17/node_modules/better-auth/dist/shared/better-auth.CpTWU-gb", { with: { "resolution-mode": "import" } }).p' is not assignable to type 'import("/Users/cesconix/workspace/issue/node_modules/.pnpm/better-auth@1.3.5_zod@4.0.17/node_modules/better-auth/dist/shared/better-auth.DSYK4jT-").p'. The types of 'options.socialProviders' are incompatible between these types. Type 'import("/Users/cesconix/workspace/issue/node_modules/.pnpm/better-auth@1.3.5_zod@4.0.17/node_modules/better-auth/dist/shared/better-auth.B-pjewPT", { with: { "resolution-mode": "import" } }).S | undefined' is not assignable to type 'import("/Users/cesconix/workspace/issue/node_modules/.pnpm/better-auth@1.3.5_zod@4.0.17/node_modules/better-auth/dist/shared/better-auth.DSvLrleU").S | undefined'. Type 'import("/Users/cesconix/workspace/issue/node_modules/.pnpm/better-auth@1.3.5_zod@4.0.17/node_modules/better-auth/dist/shared/better-auth.B-pjewPT", { with: { "resolution-mode": "import" } }).S' is not assignable to type 'import("/Users/cesconix/workspace/issue/node_modules/.pnpm/better-auth@1.3.5_zod@4.0.17/node_modules/better-auth/dist/shared/better-auth.DSvLrleU").S'. Types of property 'vk' are incompatible. Type 'import("/Users/cesconix/workspace/issue/node_modules/.pnpm/better-auth@1.3.5_zod@4.0.17/node_modules/better-auth/dist/shared/better-auth.BDR52Rf2", { with: { "resolution-mode": "import" } }).a<import("/Users/cesconix/workspace/issue/node_modules/.pnpm/better-auth@1.3.5_zod@4.0.17/node_modules/better-auth/dist/shared...' is not assignable to type 'import("/Users/cesconix/workspace/issue/node_modules/.pnpm/better-auth@1.3.5_zod@4.0.17/node_modules/better-auth/dist/shared/better-auth.BDR52Rf2").a<import("/Users/cesconix/workspace/issue/node_modules/.pnpm/better-auth@1.3.5_zod@4.0.17/node_modules/better-auth/dist/shared/better-auth.DSvLrleU").ad & { enabled?: bo...'. Type 'import("/Users/cesconix/workspace/issue/node_modules/.pnpm/better-auth@1.3.5_zod@4.0.17/node_modules/better-auth/dist/shared/better-auth.BDR52Rf2", { with: { "resolution-mode": "import" } }).a<import("/Users/cesconix/workspace/issue/node_modules/.pnpm/better-auth@1.3.5_zod@4.0.17/node_modules/better-auth/dist/shared...' is not assignable to type 'import("/Users/cesconix/workspace/issue/node_modules/.pnpm/better-auth@1.3.5_zod@4.0.17/node_modules/better-auth/dist/shared/better-auth.BDR52Rf2").a<import("/Users/cesconix/workspace/issue/node_modules/.pnpm/better-auth@1.3.5_zod@4.0.17/node_modules/better-auth/dist/shared/better-auth.DSvLrleU").ad & { enabled?: bo...'. Types of property 'lang_id' are incompatible. Type 'import("/Users/cesconix/workspace/issue/node_modules/.pnpm/better-auth@1.3.5_zod@4.0.17/node_modules/better-auth/dist/shared/better-auth.B-pjewPT", { with: { "resolution-mode": "import" } }).ac | undefined' is not assignable to type 'import("/Users/cesconix/workspace/issue/node_modules/.pnpm/better-auth@1.3.5_zod@4.0.17/node_modules/better-auth/dist/shared/better-auth.DSvLrleU").ac | undefined'. Type 'LANG.RUS' is not assignable to type 'LANG | undefined'. ```
Author
Owner

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

This TS2322 error is caused by TypeScript seeing multiple instances of the BetterAuthPlugin and AuthContext types due to ESM/CJS module resolution—so even though the types look identical, TypeScript treats them as incompatible. This usually happens if your node_modules contains more than one copy of better-auth or its types, which can occur with pnpm workspaces, nested dependencies, or mismatched versions [source].

To fix this, make sure all better-auth packages resolve to a single version and instance. Try running pnpm dedupe (or the equivalent for your package manager), and check your dependency tree with pnpm list better-auth to confirm there’s only one copy. If you’re using workspaces, ensure all packages depend on the exact same version. You can also use a resolutions field in your package.json to force a single version.

If you still see the error after deduplication, you can temporarily bypass it with // @ts-ignore on the affected line, but this doesn’t solve the underlying type identity issue [source]. If you want to dig deeper, share your dependency tree and I can help spot any duplicates or mismatches.

This is a known pitfall with strict TypeScript plugin typing in ESM projects, and similar issues have been reported with other better-auth plugins [source]. There’s currently no built-in fix in better-auth, so deduplication is the most reliable solution.

To reply, just mention @dosu.


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

@dosubot[bot] commented on GitHub (Aug 17, 2025): <!-- Answer --> This TS2322 error is caused by TypeScript seeing multiple instances of the BetterAuthPlugin and AuthContext types due to ESM/CJS module resolution—so even though the types look identical, TypeScript treats them as incompatible. This usually happens if your node_modules contains more than one copy of better-auth or its types, which can occur with pnpm workspaces, nested dependencies, or mismatched versions [[source](https://github.com/better-auth/better-auth/blob/efa60af1c2d45a735ed397171bfca513b7e202ca/packages/better-auth/src/types/plugins.ts)]. To fix this, make sure all better-auth packages resolve to a single version and instance. Try running `pnpm dedupe` (or the equivalent for your package manager), and check your dependency tree with `pnpm list better-auth` to confirm there’s only one copy. If you’re using workspaces, ensure all packages depend on the exact same version. You can also use a `resolutions` field in your package.json to force a single version. If you still see the error after deduplication, you can temporarily bypass it with `// @ts-ignore` on the affected line, but this doesn’t solve the underlying type identity issue [[source](https://github.com/better-auth/better-auth/issues/2652#issuecomment-2881801528)]. If you want to dig deeper, share your dependency tree and I can help spot any duplicates or mismatches. This is a known pitfall with strict TypeScript plugin typing in ESM projects, and similar issues have been reported with other better-auth plugins [[source](https://github.com/better-auth/better-auth/issues/1252#issuecomment-2676268573)]. There’s currently no built-in fix in better-auth, so deduplication is the most reliable solution. <!-- 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/8581a08f-99f6-420e-ade0-4fefa57aa001?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/8581a08f-99f6-420e-ade0-4fefa57aa001?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/8581a08f-99f6-420e-ade0-4fefa57aa001?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/8581a08f-99f6-420e-ade0-4fefa57aa001?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/8581a08f-99f6-420e-ade0-4fefa57aa001?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/8581a08f-99f6-420e-ade0-4fefa57aa001?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/8581a08f-99f6-420e-ade0-4fefa57aa001?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/4054)
Author
Owner

@himself65 commented on GitHub (Aug 18, 2025):

can you change moduleResolution to node16 or bundler?

@himself65 commented on GitHub (Aug 18, 2025): can you change moduleResolution to node16 or bundler?
Author
Owner

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

this should be fixed by latest beta releases.

@Kinfe123 commented on GitHub (Aug 18, 2025): this should be fixed by latest beta releases.
Author
Owner

@arikark commented on GitHub (Aug 26, 2025):

Tried using v1.3.8-beta.3 but no luck @Kinfe123

@arikark commented on GitHub (Aug 26, 2025): Tried using [v1.3.8-beta.3](https://github.com/better-auth/better-auth/releases/tag/v1.3.8-beta.3) but no luck @Kinfe123
Author
Owner

@himself65 commented on GitHub (Aug 26, 2025):

Tried using v1.3.8-beta.3 but no luck @Kinfe123

@Kinfe123, can you double-check this?

@himself65 commented on GitHub (Aug 26, 2025): > Tried using [v1.3.8-beta.3](https://github.com/better-auth/better-auth/releases/tag/v1.3.8-beta.3) but no luck [@Kinfe123](https://github.com/Kinfe123) @Kinfe123, can you double-check this?
Author
Owner

@arikark commented on GitHub (Aug 26, 2025):

Tried using v1.3.8-beta.3 but no luck @Kinfe123

@Kinfe123, can you double-check this?

Also important to note, v1.3.8-beta.3 is not compatible with Cloudflare workers (non node runtime). It uses node:sqlite, which is not compatible without a pollyfill.

@arikark commented on GitHub (Aug 26, 2025): > > Tried using [v1.3.8-beta.3](https://github.com/better-auth/better-auth/releases/tag/v1.3.8-beta.3) but no luck [@Kinfe123](https://github.com/Kinfe123) > > [@Kinfe123](https://github.com/Kinfe123), can you double-check this? Also important to note, [v1.3.8-beta.3](https://github.com/better-auth/better-auth/releases/tag/v1.3.8-beta.3) is not compatible with Cloudflare workers (non node runtime). It uses node:sqlite, which is not compatible without a pollyfill.
Author
Owner

@himself65 commented on GitHub (Aug 26, 2025):

Tried using v1.3.8-beta.3 but no luck @Kinfe123

@Kinfe123, can you double-check this?

Also important to note, v1.3.8-beta.3 is not compatible with Cloudflare workers (non node runtime). It uses node:sqlite, which is not compatible without a pollyfill.

Thanks for the feedback. I will check

@himself65 commented on GitHub (Aug 26, 2025): > > > Tried using [v1.3.8-beta.3](https://github.com/better-auth/better-auth/releases/tag/v1.3.8-beta.3) but no luck [@Kinfe123](https://github.com/Kinfe123) > > > > > > [@Kinfe123](https://github.com/Kinfe123), can you double-check this? > > Also important to note, [v1.3.8-beta.3](https://github.com/better-auth/better-auth/releases/tag/v1.3.8-beta.3) is not compatible with Cloudflare workers (non node runtime). It uses node:sqlite, which is not compatible without a pollyfill. Thanks for the feedback. I will check
Author
Owner

@himself65 commented on GitHub (Aug 26, 2025):

I didn't see the error. can you show more infomation?

@himself65 commented on GitHub (Aug 26, 2025): I didn't see the error. can you show more infomation?
Author
Owner

@himself65 commented on GitHub (Aug 28, 2025):

Fixed in 1.3.8-beta.6

Update guide: 8448c0a676

@himself65 commented on GitHub (Aug 28, 2025): Fixed in 1.3.8-beta.6 Update guide: https://github.com/LMRouter/lmrouter/commit/8448c0a6760ec8093a9db545aea1ee5e3801e23a
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#1729