[GH-ISSUE #6637] [1.4.6] Error upgrading to v1.4.6 using Tanstack Start #19209

Closed
opened 2026-04-15 18:02:29 -05:00 by GiteaMirror · 10 comments
Owner

Originally created by @jsa4000 on GitHub (Dec 9, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/6637

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

Update v1.4.6

Current vs. Expected behavior

Trying to build using this new version

plugin vite:resolve] Module "node:module" has been externalized for browser compatibility, imported by "/Users/jsantosa/Projects/Github/code-flow/node_modules/.pnpm/better-auth@1.4.6_@tanstack+react-start@1.140.0_crossws@0.4.1_srvx@0.9.7__react-dom@19._de0b205a7bf3285fe8ccbe2f1d11ba0f/node_modules/better-auth/dist/chunk-DieNfLhd.mjs". See https://vite.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.
[plugin vite:resolve] Module "node:async_hooks" has been externalized for browser compatibility, imported by "/Users/jsantosa/Projects/Github/code-flow/node_modules/.pnpm/@better-auth+core@1.4.6_@better-auth+utils@0.3.0_@better-fetch+fetch@1.1.18_better-call_414df9a6872f19f7a4a85d1e0b923f9d/node_modules/@better-auth/core/dist/async_hooks-CrTStdt6.mjs". See https://vite.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.
✓ 9209 modules transformed.
✗ Build failed in 6.38s
app:build: error during build:
app:build: ../../node_modules/.pnpm/better-auth@1.4.6_@tanstack+react-start@1.140.0_crossws@0.4.1_srvx@0.9.7__react-dom@19._de0b205a7bf3285fe8ccbe2f1d11ba0f/node_modules/better-auth/dist/chunk-DieNfLhd.mjs (1:9): "createRequire" is not exported by "__vite-browser-external", imported by "../../node_modules/.pnpm/better-auth@1.4.6_@tanstack+react-start@1.140.0_crossws@0.4.1_srvx@0.9.7__react-dom@19._de0b205a7bf3285fe8ccbe2f1d11ba0f/node_modules/better-auth/dist/chunk-DieNfLhd.mjs".
app:build: file: /Users/jsantosa/Projects/Github/code-flow/node_modules/.pnpm/better-auth@1.4.6_@tanstack+react-start@1.140.0_crossws@0.4.1_srvx@0.9.7__react-dom@19._de0b205a7bf3285fe8ccbe2f1d11ba0f/node_modules/better-auth/dist/chunk-DieNfLhd.mjs:1:9
app:build: 
app:build: 1: import { createRequire } from "node:module";
app:build:             ^
app:build: 2: 
app:build: 3: //#region rolldown:runtime
app:build: 
app:build:     at getRollupError (file:///Users/jsantosa/Projects/Github/code-flow/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/parseAst.js:401:41)
app:build:     at error (file:///Users/jsantosa/Projects/Github/code-flow/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/parseAst.js:397:42)
app:build:     at Module.error (file:///Users/jsantosa/Projects/Github/code-flow/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:16956:16)
app:build:     at Module.traceVariable (file:///Users/jsantosa/Projects/Github/code-flow/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:17412:29)
app:build:     at ModuleScope.findVariable (file:///Users/jsantosa/Projects/Github/code-flow/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:15076:39)
app:build:     at Identifier.bind (file:///Users/jsantosa/Projects/Github/code-flow/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:5423:40)
app:build:     at CallExpression.bind (file:///Users/jsantosa/Projects/Github/code-flow/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:2813:23)
app:build:     at CallExpression.bind (file:///Users/jsantosa/Projects/Github/code-flow/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:12123:15)
app:build:     at VariableDeclarator.bind (file:///Users/jsantosa/Projects/Github/code-flow/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:2813:23)
app:build:     at VariableDeclaration.bind (file:///Users/jsantosa/Projects/Github/code-flow/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:2809:28)
app:build:     at Program.bind (file:///Users/jsantosa/Projects/Github/code-flow/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:2809:28)
app:build:     at Module.bindReferences (file:///Users/jsantosa/Projects/Github/code-flow/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:16935:18)
app:build:     at Graph.sortModules (file:///Users/jsantosa/Projects/Github/code-flow/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:22746:20)
app:build:     at Graph.build (file:///Users/jsantosa/Projects/Github/code-flow/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:22644:14)
app:build:     at async file:///Users/jsantosa/Projects/Github/code-flow/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:23335:13
app:build:     at async catchUnfinishedHookActions (file:///Users/jsantosa/Projects/Github/code-flow/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:22805:16)
app:build:     at async rollupInternal (file:///Users/jsantosa/Projects/Github/code-flow/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:23330:5)
app:build:     at async buildEnvironment (file:///Users/jsantosa/Projects/Github/code-flow/node_modules/.pnpm/vite@7.2.7_@types+node@24.10.2_jiti@2.6.1_lightningcss@1.30.2_tsx@4.21.0_yaml@2.8.2/node_modules/vite/dist/node/chunks/config.js:33540:12)
app:build:     at async Object.build (file:///Users/jsantosa/Projects/Github/code-flow/node_modules/.pnpm/vite@7.2.7_@types+node@24.10.2_jiti@2.6.1_lightningcss@1.30.2_tsx@4.21.0_yaml@2.8.2/node_modules/vite/dist/node/chunks/config.js:33899:19)
app:build:     at async Object.buildApp (file:///Users/jsantosa/Projects/Github/code-flow/node_modules/.pnpm/@tanstack+start-plugin-core@1.140.0_@tanstack+react-router@1.140.0_react-dom@19.2.1_rea_abc3bd2f6c3aacc91b8d3ee05c9934f4/node_modules/@tanstack/start-plugin-core/dist/esm/plugin.js:254:17)
app:build:     at async Object.buildApp (file:///Users/jsantosa/Projects/Github/code-flow/node_modules/.pnpm/vite@7.2.7_@types+node@24.10.2_jiti@2.6.1_lightningcss@1.30.2_tsx@4.21.0_yaml@2.8.2/node_modules/vite/dist/node/chunks/config.js:33891:6)
app:build:     at async CAC.<anonymous> (file:///Users/jsantosa/Projects/Github/code-flow/node_modules/.pnpm/vite@7.2.7_@types+node@24.10.2_jiti@2.6.1_lightningcss@1.30.2_tsx@4.21.0_yaml@2.8.2/node_modules/vite/dist/node/cli.js:629:3)
app:build:  ELIFECYCLE  Command failed with exit code 1.
app:build: ERROR: command finished with error: command (/Users/jsantosa/Projects/Github/code-flow/apps/app) /Users/jsantosa/Library/pnpm/.tools/pnpm/10.25.0/bin/pnpm run build exited (1)
app#build: command (/Users/jsantosa/Projects/Github/code-flow/apps/app) /Users/jsantosa/Library/pnpm/.tools/pnpm/10.25.0/bin/pnpm run build exited (1)

What version of Better Auth are you using?

1.4.6

System info

{
  "system": {
    "platform": "darwin",
    "arch": "arm64",
    "version": "Darwin Kernel Version 25.1.0: Mon Oct 20 19:34:05 PDT 2025; root:xnu-12377.41.6~2/RELEASE_ARM64_T6041",
    "release": "25.1.0",
    "cpuCount": 14,
    "cpuModel": "Apple M4 Pro",
    "totalMemory": "48.00 GB",
    "freeMemory": "3.48 GB"
  },
  "node": {
    "version": "v24.11.1",
    "env": "development"
  },
  "packageManager": {
    "name": "npm",
    "version": "11.6.2"
  },
  "frameworks": null,
  "databases": null,
  "betterAuth": {
    "version": "Unknown",
    "config": null
  }
}

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

Client

Auth config (if applicable)


Additional context

I have tested my app with the current latest release v1.4.6

Originally created by @jsa4000 on GitHub (Dec 9, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/6637 ### Is this suited for github? - [ ] Yes, this is suited for github ### To Reproduce Update v1.4.6 ### Current vs. Expected behavior Trying to build using this new version ```bash plugin vite:resolve] Module "node:module" has been externalized for browser compatibility, imported by "/Users/jsantosa/Projects/Github/code-flow/node_modules/.pnpm/better-auth@1.4.6_@tanstack+react-start@1.140.0_crossws@0.4.1_srvx@0.9.7__react-dom@19._de0b205a7bf3285fe8ccbe2f1d11ba0f/node_modules/better-auth/dist/chunk-DieNfLhd.mjs". See https://vite.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details. [plugin vite:resolve] Module "node:async_hooks" has been externalized for browser compatibility, imported by "/Users/jsantosa/Projects/Github/code-flow/node_modules/.pnpm/@better-auth+core@1.4.6_@better-auth+utils@0.3.0_@better-fetch+fetch@1.1.18_better-call_414df9a6872f19f7a4a85d1e0b923f9d/node_modules/@better-auth/core/dist/async_hooks-CrTStdt6.mjs". See https://vite.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details. ✓ 9209 modules transformed. ✗ Build failed in 6.38s app:build: error during build: app:build: ../../node_modules/.pnpm/better-auth@1.4.6_@tanstack+react-start@1.140.0_crossws@0.4.1_srvx@0.9.7__react-dom@19._de0b205a7bf3285fe8ccbe2f1d11ba0f/node_modules/better-auth/dist/chunk-DieNfLhd.mjs (1:9): "createRequire" is not exported by "__vite-browser-external", imported by "../../node_modules/.pnpm/better-auth@1.4.6_@tanstack+react-start@1.140.0_crossws@0.4.1_srvx@0.9.7__react-dom@19._de0b205a7bf3285fe8ccbe2f1d11ba0f/node_modules/better-auth/dist/chunk-DieNfLhd.mjs". app:build: file: /Users/jsantosa/Projects/Github/code-flow/node_modules/.pnpm/better-auth@1.4.6_@tanstack+react-start@1.140.0_crossws@0.4.1_srvx@0.9.7__react-dom@19._de0b205a7bf3285fe8ccbe2f1d11ba0f/node_modules/better-auth/dist/chunk-DieNfLhd.mjs:1:9 app:build: app:build: 1: import { createRequire } from "node:module"; app:build: ^ app:build: 2: app:build: 3: //#region rolldown:runtime app:build: app:build: at getRollupError (file:///Users/jsantosa/Projects/Github/code-flow/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/parseAst.js:401:41) app:build: at error (file:///Users/jsantosa/Projects/Github/code-flow/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/parseAst.js:397:42) app:build: at Module.error (file:///Users/jsantosa/Projects/Github/code-flow/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:16956:16) app:build: at Module.traceVariable (file:///Users/jsantosa/Projects/Github/code-flow/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:17412:29) app:build: at ModuleScope.findVariable (file:///Users/jsantosa/Projects/Github/code-flow/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:15076:39) app:build: at Identifier.bind (file:///Users/jsantosa/Projects/Github/code-flow/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:5423:40) app:build: at CallExpression.bind (file:///Users/jsantosa/Projects/Github/code-flow/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:2813:23) app:build: at CallExpression.bind (file:///Users/jsantosa/Projects/Github/code-flow/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:12123:15) app:build: at VariableDeclarator.bind (file:///Users/jsantosa/Projects/Github/code-flow/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:2813:23) app:build: at VariableDeclaration.bind (file:///Users/jsantosa/Projects/Github/code-flow/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:2809:28) app:build: at Program.bind (file:///Users/jsantosa/Projects/Github/code-flow/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:2809:28) app:build: at Module.bindReferences (file:///Users/jsantosa/Projects/Github/code-flow/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:16935:18) app:build: at Graph.sortModules (file:///Users/jsantosa/Projects/Github/code-flow/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:22746:20) app:build: at Graph.build (file:///Users/jsantosa/Projects/Github/code-flow/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:22644:14) app:build: at async file:///Users/jsantosa/Projects/Github/code-flow/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:23335:13 app:build: at async catchUnfinishedHookActions (file:///Users/jsantosa/Projects/Github/code-flow/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:22805:16) app:build: at async rollupInternal (file:///Users/jsantosa/Projects/Github/code-flow/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:23330:5) app:build: at async buildEnvironment (file:///Users/jsantosa/Projects/Github/code-flow/node_modules/.pnpm/vite@7.2.7_@types+node@24.10.2_jiti@2.6.1_lightningcss@1.30.2_tsx@4.21.0_yaml@2.8.2/node_modules/vite/dist/node/chunks/config.js:33540:12) app:build: at async Object.build (file:///Users/jsantosa/Projects/Github/code-flow/node_modules/.pnpm/vite@7.2.7_@types+node@24.10.2_jiti@2.6.1_lightningcss@1.30.2_tsx@4.21.0_yaml@2.8.2/node_modules/vite/dist/node/chunks/config.js:33899:19) app:build: at async Object.buildApp (file:///Users/jsantosa/Projects/Github/code-flow/node_modules/.pnpm/@tanstack+start-plugin-core@1.140.0_@tanstack+react-router@1.140.0_react-dom@19.2.1_rea_abc3bd2f6c3aacc91b8d3ee05c9934f4/node_modules/@tanstack/start-plugin-core/dist/esm/plugin.js:254:17) app:build: at async Object.buildApp (file:///Users/jsantosa/Projects/Github/code-flow/node_modules/.pnpm/vite@7.2.7_@types+node@24.10.2_jiti@2.6.1_lightningcss@1.30.2_tsx@4.21.0_yaml@2.8.2/node_modules/vite/dist/node/chunks/config.js:33891:6) app:build: at async CAC.<anonymous> (file:///Users/jsantosa/Projects/Github/code-flow/node_modules/.pnpm/vite@7.2.7_@types+node@24.10.2_jiti@2.6.1_lightningcss@1.30.2_tsx@4.21.0_yaml@2.8.2/node_modules/vite/dist/node/cli.js:629:3) app:build:  ELIFECYCLE  Command failed with exit code 1. app:build: ERROR: command finished with error: command (/Users/jsantosa/Projects/Github/code-flow/apps/app) /Users/jsantosa/Library/pnpm/.tools/pnpm/10.25.0/bin/pnpm run build exited (1) app#build: command (/Users/jsantosa/Projects/Github/code-flow/apps/app) /Users/jsantosa/Library/pnpm/.tools/pnpm/10.25.0/bin/pnpm run build exited (1) ``` ### What version of Better Auth are you using? 1.4.6 ### System info ```bash { "system": { "platform": "darwin", "arch": "arm64", "version": "Darwin Kernel Version 25.1.0: Mon Oct 20 19:34:05 PDT 2025; root:xnu-12377.41.6~2/RELEASE_ARM64_T6041", "release": "25.1.0", "cpuCount": 14, "cpuModel": "Apple M4 Pro", "totalMemory": "48.00 GB", "freeMemory": "3.48 GB" }, "node": { "version": "v24.11.1", "env": "development" }, "packageManager": { "name": "npm", "version": "11.6.2" }, "frameworks": null, "databases": null, "betterAuth": { "version": "Unknown", "config": null } } ``` ### Which area(s) are affected? (Select all that apply) Client ### Auth config (if applicable) ```typescript ``` ### Additional context I have tested my app with the current latest release v1.4.6
GiteaMirror added the lockedbug labels 2026-04-15 18:02:30 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Dec 9, 2025):

This is a known regression in better-auth v1.4.6: Node.js-only modules like createRequire from node:module and node:async_hooks are imported in code paths that end up in browser builds, which Vite/Rollup cannot handle, causing your build to fail. This happens if you import from the default entrypoint (better-auth) or use server-only plugins or modules in client code. See issue #6635 and related discussion.

To fix this:

  • Make sure all client-side imports use better-auth/client and better-auth/client/plugins only. Audit your codebase for any imports from better-auth, better-auth/plugins, or other server-only modules in client code.
  • If you use SSO/social sign-in, initiate it from the client using authClient.api.signInSSO from better-auth/client, not from server/backend routes. Only handle the callback endpoint server-side.
  • If you still see the error, you may need to downgrade to a version before the regression (e.g., 1.3.4) or try the latest beta (e.g., 1.4.6-beta.4) as a temporary workaround.
  • Excluding better-auth from Vite's optimizeDeps may help in some cases, but it won't resolve the issue if server-only code is still imported in client bundles.

If you want help auditing your imports or need a code example, just share your import statements or a minimal reproduction.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

<!-- gh-comment-id:3632495262 --> @dosubot[bot] commented on GitHub (Dec 9, 2025): <!-- Answer --> This is a known regression in better-auth v1.4.6: Node.js-only modules like `createRequire` from `node:module` and `node:async_hooks` are imported in code paths that end up in browser builds, which Vite/Rollup cannot handle, causing your build to fail. This happens if you import from the default entrypoint (`better-auth`) or use server-only plugins or modules in client code. See [issue #6635](https://github.com/better-auth/better-auth/issues/6635) and [related discussion](https://github.com/better-auth/better-auth/issues/5539#issuecomment-3586216201). To fix this: - Make sure all client-side imports use `better-auth/client` and `better-auth/client/plugins` only. Audit your codebase for any imports from `better-auth`, `better-auth/plugins`, or other server-only modules in client code. - If you use SSO/social sign-in, initiate it from the client using `authClient.api.signInSSO` from `better-auth/client`, not from server/backend routes. Only handle the callback endpoint server-side. - If you still see the error, you may need to downgrade to a version before the regression (e.g., `1.3.4`) or try the latest beta (e.g., `1.4.6-beta.4`) as a temporary workaround. - Excluding `better-auth` from Vite's `optimizeDeps` may help in some cases, but it won't resolve the issue if server-only code is still imported in client bundles. If you want help auditing your imports or need a code example, just share your import statements or a minimal reproduction. <!-- 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/af598a08-81bc-42fa-83b8-c289d054e237?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/af598a08-81bc-42fa-83b8-c289d054e237?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/af598a08-81bc-42fa-83b8-c289d054e237?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/af598a08-81bc-42fa-83b8-c289d054e237?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/af598a08-81bc-42fa-83b8-c289d054e237?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/af598a08-81bc-42fa-83b8-c289d054e237?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/af598a08-81bc-42fa-83b8-c289d054e237?feedback_type=other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=This%20is%20a%20known%20regression%20in%20better-auth%20v1.4.6%3A%20Node.js-only%20modules%20like%20%60createRequire%60%20from%20%60node%3Amodule%60%20and%20%60node%3Aasync_hooks%60%20are%20imported%20in%20code%20paths%20that%20end%20up%20in%20browser%20builds%2C%20which%20Vite/Rollup%20cannot%20handle%2C%20causing%20your%20build%20to%20fail.%20This%20happens%20if%20you%20import%20from%20the%20default%20entrypoint%20%28%60better-auth%60%29%20or%20use%20server-only%20plugins%20or%20modules%20in%20client%20code.%20See%20%5Bissue%20%236635%5D%28https%3A//github.com/better-auth/better-auth/issues/6635%29%20and%20%5Brelated%20discussion%5D%28https%3A//github.com/better-auth/better-auth/issues/5539%23issuecomment-3586216201%29.%0A%0ATo%20fix%20this%3A%0A%0A-%20Make%20sure%20all%20client-side%20imports%20use%20%60better-auth/client%60%20and%20%60better-auth/client/plugins%60%20only.%20Audit%20your%20codebase%20for%20any%20imports%20from%20%60better-auth%60%2C%20%60better-auth/plugins%60%2C%20or%20other%20server-only%20modules%20in%20client%20code.%0A-%20If%20you%20use%20SSO/social%20sign-in%2C%20initiate%20it%20from%20the%20client%20using%20%60authClient.api.signInSSO%60%20from%20%60better-auth/client%60%2C%20not%20from%20server/backend%20routes.%20Only%20handle%20the%20callback%20endpoint%20server-side.%0A-%20If%20you%20still%20see%20the%20error%2C%20you%20may%20need%20to%20downgrade%20to%20a%20version%20before%20the%20regression%20%28e.g.%2C%20%601.3.4%60%29%20or%20try%20the%20latest%20beta%20%28e.g.%2C%20%601.4.6-beta.4%60%29%20as%20a%20temporary%20workaround.%0A-%20Excluding%20%60better-auth%60%20from%20Vite%27s%20%60optimizeDeps%60%20may%20help%20in%20some%20cases%2C%20but%20it%20won%27t%20resolve%20the%20issue%20if%20server-only%20code%20is%20still%20imported%20in%20client%20bundles.%0A%0AIf%20you%20want%20help%20auditing%20your%20imports%20or%20need%20a%20code%20example%2C%20just%20share%20your%20import%20statements%20or%20a%20minimal%20reproduction.)&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/6637)
Author
Owner

@jsa4000 commented on GitHub (Dec 9, 2025):

@dosu the solution was to rollback to previous version 1.4.5

<!-- gh-comment-id:3632571266 --> @jsa4000 commented on GitHub (Dec 9, 2025): @dosu the solution was to rollback to previous version 1.4.5
Author
Owner

@dosubot[bot] commented on GitHub (Dec 9, 2025):

Rolling back to v1.4.5 is a solid workaround—this regression in v1.4.6 happens because Node.js-only modules like createRequire and async_hooks are imported in code paths that end up in browser builds, which Vite can't handle. If you want to upgrade in the future, keep an eye out for releases or betas that address this issue, or let me know if you want help auditing your imports to avoid server-only code in client bundles.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

<!-- gh-comment-id:3632574536 --> @dosubot[bot] commented on GitHub (Dec 9, 2025): <!-- Answer --> Rolling back to v1.4.5 is a solid workaround—this regression in v1.4.6 happens because Node.js-only modules like createRequire and async_hooks are imported in code paths that end up in browser builds, which Vite can't handle. If you want to upgrade in the future, keep an eye out for releases or betas that address this issue, or let me know if you want help auditing your imports to avoid server-only code in client bundles. <!-- 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/756ba03f-6612-4476-bbbd-0ee382d68b35?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/756ba03f-6612-4476-bbbd-0ee382d68b35?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/756ba03f-6612-4476-bbbd-0ee382d68b35?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/756ba03f-6612-4476-bbbd-0ee382d68b35?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/756ba03f-6612-4476-bbbd-0ee382d68b35?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/756ba03f-6612-4476-bbbd-0ee382d68b35?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/756ba03f-6612-4476-bbbd-0ee382d68b35?feedback_type=other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=Rolling%20back%20to%20v1.4.5%20is%20a%20solid%20workaround%E2%80%94this%20regression%20in%20v1.4.6%20happens%20because%20Node.js-only%20modules%20like%20createRequire%20and%20async_hooks%20are%20imported%20in%20code%20paths%20that%20end%20up%20in%20browser%20builds%2C%20which%20Vite%20can%27t%20handle.%20If%20you%20want%20to%20upgrade%20in%20the%20future%2C%20keep%20an%20eye%20out%20for%20releases%20or%20betas%20that%20address%20this%20issue%2C%20or%20let%20me%20know%20if%20you%20want%20help%20auditing%20your%20imports%20to%20avoid%20server-only%20code%20in%20client%20bundles.)&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/6637)
Author
Owner

@jsa4000 commented on GitHub (Dec 11, 2025):

@dosu some advance with this issue?

<!-- gh-comment-id:3641571638 --> @jsa4000 commented on GitHub (Dec 11, 2025): @dosu some advance with this issue?
Author
Owner

@dosubot[bot] commented on GitHub (Dec 11, 2025):

Yes, there’s progress! The regression in v1.4.6 is confirmed and a fix was merged to prevent static Node.js imports from breaking browser and edge builds. This fix is available in beta releases after v1.4.6—users report that installing the latest beta (like 1.4.7-beta.2) resolves the issue source, source.

If you want to upgrade, try the latest beta version. If you prefer to avoid betas, keep an eye out for the next stable release. The technical root cause was static imports of Node.js modules (like createRequire and async_hooks) in code paths that sometimes end up in browser bundles; the fix uses dynamic imports and runtime detection to avoid this.

If you can’t upgrade, you can still downgrade to v1.4.5 or audit your imports to make sure you only use client entrypoints (better-auth/client) in browser code. Let me know if you want help with migration or import auditing!

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

<!-- gh-comment-id:3641578147 --> @dosubot[bot] commented on GitHub (Dec 11, 2025): <!-- Answer --> Yes, there’s progress! The regression in v1.4.6 is confirmed and a fix was merged to prevent static Node.js imports from breaking browser and edge builds. This fix is available in beta releases after v1.4.6—users report that installing the latest beta (like `1.4.7-beta.2`) resolves the issue [source](https://github.com/better-auth/better-auth/issues/6665), [source](https://github.com/better-auth/better-auth/pull/3947). If you want to upgrade, try the latest beta version. If you prefer to avoid betas, keep an eye out for the next stable release. The technical root cause was static imports of Node.js modules (like `createRequire` and `async_hooks`) in code paths that sometimes end up in browser bundles; the fix uses dynamic imports and runtime detection to avoid this. If you can’t upgrade, you can still downgrade to v1.4.5 or audit your imports to make sure you only use client entrypoints (`better-auth/client`) in browser code. Let me know if you want help with migration or import auditing! <!-- 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/f7ecc158-39b9-4e64-af15-64351d76d6cb?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/f7ecc158-39b9-4e64-af15-64351d76d6cb?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/f7ecc158-39b9-4e64-af15-64351d76d6cb?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/f7ecc158-39b9-4e64-af15-64351d76d6cb?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/f7ecc158-39b9-4e64-af15-64351d76d6cb?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/f7ecc158-39b9-4e64-af15-64351d76d6cb?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/f7ecc158-39b9-4e64-af15-64351d76d6cb?feedback_type=other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=Yes%2C%20there%E2%80%99s%20progress%21%20The%20regression%20in%20v1.4.6%20is%20confirmed%20and%20a%20fix%20was%20merged%20to%20prevent%20static%20Node.js%20imports%20from%20breaking%20browser%20and%20edge%20builds.%20This%20fix%20is%20available%20in%20beta%20releases%20after%20v1.4.6%E2%80%94users%20report%20that%20installing%20the%20latest%20beta%20%28like%20%601.4.7-beta.2%60%29%20resolves%20the%20issue%20%5Bsource%5D%28https%3A//github.com/better-auth/better-auth/issues/6665%29%2C%20%5Bsource%5D%28https%3A//github.com/better-auth/better-auth/pull/3947%29.%0A%0AIf%20you%20want%20to%20upgrade%2C%20try%20the%20latest%20beta%20version.%20If%20you%20prefer%20to%20avoid%20betas%2C%20keep%20an%20eye%20out%20for%20the%20next%20stable%20release.%20The%20technical%20root%20cause%20was%20static%20imports%20of%20Node.js%20modules%20%28like%20%60createRequire%60%20and%20%60async_hooks%60%29%20in%20code%20paths%20that%20sometimes%20end%20up%20in%20browser%20bundles%3B%20the%20fix%20uses%20dynamic%20imports%20and%20runtime%20detection%20to%20avoid%20this.%0A%0AIf%20you%20can%E2%80%99t%20upgrade%2C%20you%20can%20still%20downgrade%20to%20v1.4.5%20or%20audit%20your%20imports%20to%20make%20sure%20you%20only%20use%20client%20entrypoints%20%28%60better-auth/client%60%29%20in%20browser%20code.%20Let%20me%20know%20if%20you%20want%20help%20with%20migration%20or%20import%20auditing%21)&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/6637)
Author
Owner

@0xJJW commented on GitHub (Dec 13, 2025):

@jsa4000 In case it helps you resolve the issue in your project, I tracked the issue down to two imports which were included in my client bundle.

import { generateId } from "better-auth";
import { sessionSchema, userSchema } from "better-auth/db";

If you have any custom plugins or use any utilities imported from better-auth or better-auth/db, I recommend starting with those.

<!-- gh-comment-id:3649753255 --> @0xJJW commented on GitHub (Dec 13, 2025): @jsa4000 In case it helps you resolve the issue in your project, I tracked the issue down to two imports which were included in my client bundle. ``` import { generateId } from "better-auth"; import { sessionSchema, userSchema } from "better-auth/db"; ``` If you have any custom plugins or use any utilities imported from `better-auth` or `better-auth/db`, I recommend starting with those.
Author
Owner

@jsa4000 commented on GitHub (Dec 13, 2025):

Thanks @0xJJW, using the latest beta version 1.4.7-beta.4 solves the issue, and also the other warnings I was getting like "node:async_hooks"

<!-- gh-comment-id:3649758714 --> @jsa4000 commented on GitHub (Dec 13, 2025): Thanks @0xJJW, using the latest beta version `1.4.7-beta.4` solves the issue, and also the other warnings I was getting like "node:async_hooks"
Author
Owner

@0xJJW commented on GitHub (Dec 13, 2025):

Thanks for the swift response @jsa4000. That's good to know 👍. I saw a few related Cloudflare issues and hoped 1.4.7-beta.2+ would resolve the Tanstack Start issue.

Unfortunately, I can't easily upgrade to beta versions because we rely heavily on internal methods and fork plugins like Organisations. Going from 1.3.x to 1.4.6 was a big job in itself, with the introduction of better-auth/core and adapter changes.

I look forward to 1.4.7

Have a great Sunday.

<!-- gh-comment-id:3649767835 --> @0xJJW commented on GitHub (Dec 13, 2025): Thanks for the swift response @jsa4000. That's good to know 👍. I saw a few related Cloudflare issues and hoped `1.4.7-beta.2+` would resolve the Tanstack Start issue. Unfortunately, I can't easily upgrade to beta versions because we rely heavily on internal methods and fork plugins like Organisations. Going from `1.3.x` to `1.4.6` was a big job in itself, with the introduction of `better-auth/core` and adapter changes. I look forward to `1.4.7` Have a great Sunday.
Author
Owner

@bytaesu commented on GitHub (Jan 27, 2026):

I’m closing this, since this issue seems to be fixed in the current version.

Thanks for your report 🙂

<!-- gh-comment-id:3802926234 --> @bytaesu commented on GitHub (Jan 27, 2026): I’m closing this, since this issue seems to be fixed in the current version. Thanks for your report 🙂
Author
Owner

@github-actions[bot] commented on GitHub (Apr 1, 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:4166562211 --> @github-actions[bot] commented on GitHub (Apr 1, 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#19209