[GH-ISSUE #7386] Could not resolve "#tanstack-router-entry" when used with tanstack router + vite #19430

Closed
opened 2026-04-15 18:30:28 -05:00 by GiteaMirror · 20 comments
Owner

Originally created by @ammubhave on GitHub (Jan 15, 2026).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/7386

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

  1. Create a tanstack start app that uses better-auth and cloudflare-vite plugin.
  2. Run the vite dev command.

Current vs. Expected behavior

Until 1.4.12 this used to work.
This broke in 1.4.13 and it now produces the following error:

✘ [ERROR] Could not resolve "#tanstack-router-entry"

    node_modules/.pnpm/@tanstack+start-server-core@1.149.3/node_modules/@tanstack/start-server-core/dist/esm/createStartHandler.js:25:35:
      25 │   const routerEntry = await import("#tanstack-router-entry");
         ╵                                    ~~~~~~~~~~~~~~~~~~~~~~~~

  The package import "#tanstack-router-entry" is not defined in this "imports" map:

    node_modules/.pnpm/@tanstack+start-server-core@1.149.3/node_modules/@tanstack/start-server-core/package.json:49:13:
      49 │   "imports": {
         ╵              ^

  You can mark the path "#tanstack-router-entry" as external to exclude it from the bundle, which
  will remove this error and leave the unresolved path in the bundle. You can also add ".catch()"
  here to handle this failure at run-time instead of bundle-time.

What version of Better Auth are you using?

1.4.13

System info

{
  "system": {
    "platform": "darwin",
    "arch": "arm64",
    "version": "Darwin Kernel Version 25.2.0: Tue Nov 18 21:09:56 PST 2025; root:xnu-12377.61.12~1/RELEASE_ARM64_T6041",
    "release": "25.2.0",
    "cpuCount": 16,
    "cpuModel": "Apple M4 Max",
    "totalMemory": "64.00 GB",
    "freeMemory": "19.02 GB"
  },
  "node": {
    "version": "v24.11.1",
    "env": "development"
  },
  "packageManager": {
    "name": "npm",
    "version": "11.6.2"
  },
  "frameworks": [
    {
      "name": "react",
      "version": "^19.2.3"
    },
    {
      "name": "hono",
      "version": "^4.11.4"
    }
  ],
  "databases": [
    {
      "name": "@libsql/client",
      "version": "^0.17.0"
    },
    {
      "name": "drizzle",
      "version": "^0.45.1"
    }
  ],
  "betterAuth": {
    "version": "Unknown",
    "config": null,
    "error": "Couldn't read your auth config. Make sure to default export your auth instance or to export as a variable named auth."
  }
}

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

Package

Auth config (if applicable)

import { betterAuth } from "better-auth"
export const auth = betterAuth({
  emailAndPassword: {  
    enabled: true
  },
});

Using `organization`, `captcha`, `username`, and `tanstackStartCookies` plugins

Additional context

Reverting back to 1.4.12 fixes this issue.

Something in these commits is incorrect https://github.com/better-auth/better-auth/compare/v1.4.12...v1.4.13

Could be 3fa5e4179c ?

Originally created by @ammubhave on GitHub (Jan 15, 2026). Original GitHub issue: https://github.com/better-auth/better-auth/issues/7386 ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce 1. Create a tanstack start app that uses better-auth and cloudflare-vite plugin. 2. Run the `vite dev` command. ### Current vs. Expected behavior Until 1.4.12 this used to work. This broke in 1.4.13 and it now produces the following error: ``` ✘ [ERROR] Could not resolve "#tanstack-router-entry" node_modules/.pnpm/@tanstack+start-server-core@1.149.3/node_modules/@tanstack/start-server-core/dist/esm/createStartHandler.js:25:35: 25 │ const routerEntry = await import("#tanstack-router-entry"); ╵ ~~~~~~~~~~~~~~~~~~~~~~~~ The package import "#tanstack-router-entry" is not defined in this "imports" map: node_modules/.pnpm/@tanstack+start-server-core@1.149.3/node_modules/@tanstack/start-server-core/package.json:49:13: 49 │ "imports": { ╵ ^ You can mark the path "#tanstack-router-entry" as external to exclude it from the bundle, which will remove this error and leave the unresolved path in the bundle. You can also add ".catch()" here to handle this failure at run-time instead of bundle-time. ``` ### What version of Better Auth are you using? 1.4.13 ### System info ```bash { "system": { "platform": "darwin", "arch": "arm64", "version": "Darwin Kernel Version 25.2.0: Tue Nov 18 21:09:56 PST 2025; root:xnu-12377.61.12~1/RELEASE_ARM64_T6041", "release": "25.2.0", "cpuCount": 16, "cpuModel": "Apple M4 Max", "totalMemory": "64.00 GB", "freeMemory": "19.02 GB" }, "node": { "version": "v24.11.1", "env": "development" }, "packageManager": { "name": "npm", "version": "11.6.2" }, "frameworks": [ { "name": "react", "version": "^19.2.3" }, { "name": "hono", "version": "^4.11.4" } ], "databases": [ { "name": "@libsql/client", "version": "^0.17.0" }, { "name": "drizzle", "version": "^0.45.1" } ], "betterAuth": { "version": "Unknown", "config": null, "error": "Couldn't read your auth config. Make sure to default export your auth instance or to export as a variable named auth." } } ``` ### Which area(s) are affected? (Select all that apply) Package ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth" export const auth = betterAuth({ emailAndPassword: { enabled: true }, }); Using `organization`, `captcha`, `username`, and `tanstackStartCookies` plugins ``` ### Additional context Reverting back to 1.4.12 fixes this issue. Something in these commits is incorrect https://github.com/better-auth/better-auth/compare/v1.4.12...v1.4.13 Could be https://github.com/better-auth/better-auth/commit/3fa5e4179cd8394afb15b8fc6e1366832e569c6a ?
GiteaMirror added the locked label 2026-04-15 18:30:28 -05:00
Author
Owner

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

It looks like you are encountering an issue with the error message Could not resolve "#tanstack-router-entry" when using Better Auth with TanStack Router and Vite. This problem seems to have started in version 1.4.13, as you noted that it was working fine in 1.4.12.

To address this issue, the following steps may help:

  1. Check Import Statements: Make sure to use the correct import statement for TanStack Cookies:

    import { tanstackStartCookies } from "better-auth/tanstack-start";
    

    This has been noted to prevent the error from occurring in a similar case [1].

  2. Externalizing Imports: If the issue persists, consider marking #tanstack-router-entry as external. This approach will prevent bundling the path, thus potentially resolving the error. You can do this in your Vite configuration.

  3. Reverting Version: If these steps do not resolve the issue, reverting back to version 1.4.12 is a viable workaround until a permanent fix is released.

  4. Tracking the Issue: There is ongoing discussion and tracking of this error in the community, so keeping an eye on current issues related to Better Auth and TanStack Router could provide updates or drafts for patches.

If you've tried these solutions and nothing works, it might be beneficial to tag @bekacru or @ping__ for more tailored assistance.

Have you implemented any of these troubleshooting steps yet? Let me know if you need further help!

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

DiagramDiscordGitHub

Diagram Join Star

<!-- gh-comment-id:3755136270 --> @better-auth-agent[bot] commented on GitHub (Jan 15, 2026): It looks like you are encountering an issue with the error message `Could not resolve "#tanstack-router-entry"` when using Better Auth with TanStack Router and Vite. This problem seems to have started in version 1.4.13, as you noted that it was working fine in 1.4.12. To address this issue, the following steps may help: 1. **Check Import Statements**: Make sure to use the correct import statement for TanStack Cookies: ```javascript import { tanstackStartCookies } from "better-auth/tanstack-start"; ``` This has been noted to prevent the error from occurring in a similar case [[1]](https://github.com/better-auth/better-auth/issues/6341). 2. **Externalizing Imports**: If the issue persists, consider marking `#tanstack-router-entry` as external. This approach will prevent bundling the path, thus potentially resolving the error. You can do this in your Vite configuration. 3. **Reverting Version**: If these steps do not resolve the issue, reverting back to version 1.4.12 is a viable workaround until a permanent fix is released. 4. **Tracking the Issue**: There is ongoing discussion and tracking of this error in the community, so keeping an eye on current issues related to Better Auth and TanStack Router could provide updates or drafts for patches. If you've tried these solutions and nothing works, it might be beneficial to tag @bekacru or @ping__ for more tailored assistance. Have you implemented any of these troubleshooting steps yet? Let me know if you need further help! _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)
Author
Owner

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

Hi @ammubhave,

I've also confirmed this issue, and adding the following to vite.config temporarily fixes it. However, this is something that should be properly addressed. We are looking into this!

optimizeDeps: {                                                                                                   
   exclude: ['@tanstack/start-server-core']                                                         
},
<!-- gh-comment-id:3755296714 --> @bytaesu commented on GitHub (Jan 15, 2026): Hi @ammubhave, I've also confirmed this issue, and adding the following to vite.config temporarily fixes it. However, this is something that should be properly addressed. We are looking into this! ```ts optimizeDeps: { exclude: ['@tanstack/start-server-core'] }, ``` - It seems related to this PR https://github.com/better-auth/better-auth/pull/7340 - cc @himself65
Author
Owner

@himself65 commented on GitHub (Jan 15, 2026):

Upstream: https://github.com/TanStack/router/issues/5795

<!-- gh-comment-id:3755386972 --> @himself65 commented on GitHub (Jan 15, 2026): Upstream: https://github.com/TanStack/router/issues/5795
Author
Owner

@himself65 commented on GitHub (Jan 15, 2026):

86605e3858/packages/start-server-core/vite.config.ts (L27-L32)

<!-- gh-comment-id:3755401798 --> @himself65 commented on GitHub (Jan 15, 2026): https://github.com/TanStack/router/blob/86605e3858580e8ac68207031968890869f6bbc6/packages/start-server-core/vite.config.ts#L27-L32
Author
Owner

@himself65 commented on GitHub (Jan 15, 2026):

I just realized it's because TanStack has its own custom Vite config. I think we shouldn't use those peer deps directly.

I'm fixing that rn

<!-- gh-comment-id:3755429139 --> @himself65 commented on GitHub (Jan 15, 2026): I just realized it's because TanStack has its own custom Vite config. I think we shouldn't use those peer deps directly. I'm fixing that rn
Author
Owner

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

@himself65, do we need to add e2e tests for integration plugins?

<!-- gh-comment-id:3755461733 --> @bytaesu commented on GitHub (Jan 15, 2026): @himself65, do we need to add e2e tests for integration plugins?
Author
Owner

@himself65 commented on GitHub (Jan 15, 2026):

@himself65, do we need to add e2e tests for integration plugins?

No, it isn't worth

<!-- gh-comment-id:3755473793 --> @himself65 commented on GitHub (Jan 15, 2026): > [@himself65](https://github.com/himself65), do we need to add e2e tests for integration plugins? No, it isn't worth
Author
Owner

@vincentparrett commented on GitHub (Jan 15, 2026):

I'm still seeing this issue with the latest beta and tanstack (react) 1.150.0

<!-- gh-comment-id:3757369632 --> @vincentparrett commented on GitHub (Jan 15, 2026): I'm still seeing this issue with the latest beta and tanstack (react) 1.150.0
Author
Owner

@dotnize commented on GitHub (Jan 17, 2026):

Hi @himself65 this is still not fixed in 1.4.14 (which includes the fix based on the changelog)

Can this issue be reopened?

Also this is the third time this issue has resurfaced, repeatedly caused by pretty much the same PRs attempting to support both Solid and React versions of tanstack start:

  1. https://github.com/better-auth/better-auth/pull/6045
  2. https://github.com/better-auth/better-auth/pull/6235
  3. https://github.com/better-auth/better-auth/pull/7340
<!-- gh-comment-id:3762703346 --> @dotnize commented on GitHub (Jan 17, 2026): Hi @himself65 this is still not fixed in `1.4.14` (which includes the fix based on the changelog) Can this issue be reopened? Also this is the third time this issue has resurfaced, repeatedly caused by pretty much the same PRs attempting to support both Solid and React versions of tanstack start: 1. https://github.com/better-auth/better-auth/pull/6045 2. https://github.com/better-auth/better-auth/pull/6235 3. https://github.com/better-auth/better-auth/pull/7340
Author
Owner

@rnkdsh commented on GitHub (Jan 17, 2026):

Yes right it's not working in 1.4.14

<!-- gh-comment-id:3762822328 --> @rnkdsh commented on GitHub (Jan 17, 2026): Yes right it's not working in 1.4.14
Author
Owner

@Zykaz commented on GitHub (Jan 17, 2026):

Correct, the issue persists, and the error has not been resolved

  "dependencies": {
    "@tanstack/react-devtools": "^0.9.2",
    "@tanstack/react-router": "^1.150.0",
    "@tanstack/react-router-devtools": "^1.150.0",
    "@tanstack/react-start": "^1.150.0",
    "better-auth": "^1.4.14"
}
<!-- gh-comment-id:3762837551 --> @Zykaz commented on GitHub (Jan 17, 2026): Correct, the issue persists, and the error has not been resolved ``` "dependencies": { "@tanstack/react-devtools": "^0.9.2", "@tanstack/react-router": "^1.150.0", "@tanstack/react-router-devtools": "^1.150.0", "@tanstack/react-start": "^1.150.0", "better-auth": "^1.4.14" } ```
Author
Owner

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

I'll check this 🧐

<!-- gh-comment-id:3762924240 --> @bytaesu commented on GitHub (Jan 17, 2026): I'll check this 🧐
Author
Owner

@angelocala94 commented on GitHub (Jan 17, 2026):

I temporarily fixed the issue by adding the following to my vite.config.ts:

optimizeDeps: {
 exclude: ['@tanstack/start-server-core'],
},

Of course this is a workaround.

<!-- gh-comment-id:3764443670 --> @angelocala94 commented on GitHub (Jan 17, 2026): I temporarily fixed the issue by adding the following to my `vite.config.ts`: ``` optimizeDeps: { exclude: ['@tanstack/start-server-core'], }, ``` Of course this is a workaround.
Author
Owner

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

Alright, I confirmed that this issue started with https://github.com/better-auth/better-auth/pull/7340 (v1.4.12 -> v1.4.13), and v1.4.14 does not fix this. v1.4.12 works without any issues on the latest TanStack Start.

We're currently discussing this 🙂

<!-- gh-comment-id:3764485540 --> @bytaesu commented on GitHub (Jan 17, 2026): Alright, I confirmed that this issue started with https://github.com/better-auth/better-auth/pull/7340 (**_v1.4.12_** -> **_v1.4.13_**), and **_v1.4.14_** does not fix this. **_v1.4.12_** works without any issues on the latest TanStack Start. We're currently discussing this 🙂
Author
Owner

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

I temporarily fixed the issue by adding the following to my vite.config.ts:

optimizeDeps: {
 exclude: ['@tanstack/start-server-core'],
},

Of course this is a workaround.

Yeah, we should support seamless integration out of the box... will fix this 🫡

<!-- gh-comment-id:3764486955 --> @bytaesu commented on GitHub (Jan 17, 2026): > I temporarily fixed the issue by adding the following to my `vite.config.ts`: > > ``` > optimizeDeps: { > exclude: ['@tanstack/start-server-core'], > }, > ``` > > Of course this is a workaround. Yeah, we should support seamless integration out of the box... will fix this 🫡
Author
Owner

@josippapez commented on GitHub (Jan 20, 2026):

@bytaesu (sorry for the ping) It seems like this issue got introduced again with the latest versions of the packages (tanstack + better auth). Once i comment out the tanstackStartCookies import and plugin in the createAuthClient my build passes otherwise i get this:

vite v7.3.1 building client environment for production...
[plugin vite:resolve] Module "node:async_hooks" has been externalized for browser compatibility, imported by "/Users/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/@tanstack+start-server-core@1.153.2_crossws@0.4.1_srvx@0.9.6_/node_modules/@tanstack/start-server-core/dist/esm/request-response.js". See https://vite.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.
[plugin vite:resolve] Module "node:stream/web" has been externalized for browser compatibility, imported by "/Users/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/@tanstack+router-core@1.153.2/node_modules/@tanstack/router-core/dist/esm/ssr/transformStreamWithRouter.js". See https://vite.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.
[plugin vite:resolve] Module "node:stream" has been externalized for browser compatibility, imported by "/Users/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/@tanstack+router-core@1.153.2/node_modules/@tanstack/router-core/dist/esm/ssr/transformStreamWithRouter.js". See https://vite.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.
[plugin vite:resolve] Module "node:stream" has been externalized for browser compatibility, imported by "/Users/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/@tanstack+react-router@1.153.2_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@tanstack/react-router/dist/esm/ssr/renderRouterToStream.js". 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/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/@tanstack+start-storage-context@1.153.2/node_modules/@tanstack/start-storage-context/dist/esm/async-local-storage.js". See https://vite.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.
 4331 modules transformed.
 Build failed in 3.62s
error during build:
node_modules/.pnpm/@tanstack+router-core@1.153.2/node_modules/@tanstack/router-core/dist/esm/ssr/transformStreamWithRouter.js (2:9): "Readable" is not exported by "__vite-browser-external", imported by "node_modules/.pnpm/@tanstack+router-core@1.153.2/node_modules/@tanstack/router-core/dist/esm/ssr/transformStreamWithRouter.js".
file: /Users/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/@tanstack+router-core@1.153.2/node_modules/@tanstack/router-core/dist/esm/ssr/transformStreamWithRouter.js:2:9

1: import { ReadableStream } from "node:stream/web";
2: import { Readable } from "node:stream";
            ^
3: import { TSR_SCRIPT_BARRIER_ID } from "./constants.js";
4: function transformReadableStreamWithRouter(router, routerStream) {

    at getRollupError (file:///Users/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/parseAst.js:401:41)
    at error (file:///Users/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/parseAst.js:397:42)
    at Module.error (file:///Users/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:16956:16)
    at Module.traceVariable (file:///Users/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:17412:29)
    at ModuleScope.findVariable (file:///Users/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:15076:39)
    at FunctionScope.findVariable (file:///Users/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:5649:38)
    at FunctionBodyScope.findVariable (file:///Users/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:5649:38)
    at MemberExpression.bind (file:///Users/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:7363:49)
    at CallExpression.bind (file:///Users/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:2813:23)
    at CallExpression.bind (file:///Users/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:12123:15)
ELIFECYCLECommand failed with exit code 1.

<!-- gh-comment-id:3775276749 --> @josippapez commented on GitHub (Jan 20, 2026): @bytaesu (sorry for the ping) It seems like this issue got introduced again with the latest versions of the packages (tanstack + better auth). Once i comment out the `tanstackStartCookies` import and plugin in the createAuthClient my build passes otherwise i get this: ```ts vite v7.3.1 building client environment for production... [plugin vite:resolve] Module "node:async_hooks" has been externalized for browser compatibility, imported by "/Users/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/@tanstack+start-server-core@1.153.2_crossws@0.4.1_srvx@0.9.6_/node_modules/@tanstack/start-server-core/dist/esm/request-response.js". See https://vite.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details. [plugin vite:resolve] Module "node:stream/web" has been externalized for browser compatibility, imported by "/Users/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/@tanstack+router-core@1.153.2/node_modules/@tanstack/router-core/dist/esm/ssr/transformStreamWithRouter.js". See https://vite.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details. [plugin vite:resolve] Module "node:stream" has been externalized for browser compatibility, imported by "/Users/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/@tanstack+router-core@1.153.2/node_modules/@tanstack/router-core/dist/esm/ssr/transformStreamWithRouter.js". See https://vite.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details. [plugin vite:resolve] Module "node:stream" has been externalized for browser compatibility, imported by "/Users/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/@tanstack+react-router@1.153.2_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@tanstack/react-router/dist/esm/ssr/renderRouterToStream.js". 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/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/@tanstack+start-storage-context@1.153.2/node_modules/@tanstack/start-storage-context/dist/esm/async-local-storage.js". See https://vite.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details. ✓ 4331 modules transformed. ✗ Build failed in 3.62s error during build: node_modules/.pnpm/@tanstack+router-core@1.153.2/node_modules/@tanstack/router-core/dist/esm/ssr/transformStreamWithRouter.js (2:9): "Readable" is not exported by "__vite-browser-external", imported by "node_modules/.pnpm/@tanstack+router-core@1.153.2/node_modules/@tanstack/router-core/dist/esm/ssr/transformStreamWithRouter.js". file: /Users/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/@tanstack+router-core@1.153.2/node_modules/@tanstack/router-core/dist/esm/ssr/transformStreamWithRouter.js:2:9 1: import { ReadableStream } from "node:stream/web"; 2: import { Readable } from "node:stream"; ^ 3: import { TSR_SCRIPT_BARRIER_ID } from "./constants.js"; 4: function transformReadableStreamWithRouter(router, routerStream) { at getRollupError (file:///Users/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/parseAst.js:401:41) at error (file:///Users/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/parseAst.js:397:42) at Module.error (file:///Users/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:16956:16) at Module.traceVariable (file:///Users/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:17412:29) at ModuleScope.findVariable (file:///Users/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:15076:39) at FunctionScope.findVariable (file:///Users/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:5649:38) at FunctionBodyScope.findVariable (file:///Users/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:5649:38) at MemberExpression.bind (file:///Users/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:7363:49) at CallExpression.bind (file:///Users/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:2813:23) at CallExpression.bind (file:///Users/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:12123:15)  ELIFECYCLE  Command failed with exit code 1. ```
Author
Owner

@himself65 commented on GitHub (Jan 20, 2026):

@bytaesu (sorry for the ping) It seems like this issue got introduced again with the latest versions of the packages (tanstack + better auth). Once i comment out the tanstackStartCookies import and plugin in the createAuthClient my build passes otherwise i get this:

vite v7.3.1 building client environment for production...
[plugin vite:resolve] Module "node:async_hooks" has been externalized for browser compatibility, imported by "/Users/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/@tanstack+start-server-core@1.153.2_crossws@0.4.1_srvx@0.9.6_/node_modules/@tanstack/start-server-core/dist/esm/request-response.js". See https://vite.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.
[plugin vite:resolve] Module "node:stream/web" has been externalized for browser compatibility, imported by "/Users/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/@tanstack+router-core@1.153.2/node_modules/@tanstack/router-core/dist/esm/ssr/transformStreamWithRouter.js". See https://vite.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.
[plugin vite:resolve] Module "node:stream" has been externalized for browser compatibility, imported by "/Users/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/@tanstack+router-core@1.153.2/node_modules/@tanstack/router-core/dist/esm/ssr/transformStreamWithRouter.js". See https://vite.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.
[plugin vite:resolve] Module "node:stream" has been externalized for browser compatibility, imported by "/Users/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/@tanstack+react-router@1.153.2_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@tanstack/react-router/dist/esm/ssr/renderRouterToStream.js". 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/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/@tanstack+start-storage-context@1.153.2/node_modules/@tanstack/start-storage-context/dist/esm/async-local-storage.js". See https://vite.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.
✓ 4331 modules transformed.
✗ Build failed in 3.62s
error during build:
node_modules/.pnpm/@tanstack+router-core@1.153.2/node_modules/@tanstack/router-core/dist/esm/ssr/transformStreamWithRouter.js (2:9): "Readable" is not exported by "__vite-browser-external", imported by "node_modules/.pnpm/@tanstack+router-core@1.153.2/node_modules/@tanstack/router-core/dist/esm/ssr/transformStreamWithRouter.js".
file: /Users/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/@tanstack+router-core@1.153.2/node_modules/@tanstack/router-core/dist/esm/ssr/transformStreamWithRouter.js:2:9

1: import { ReadableStream } from "node:stream/web";
2: import { Readable } from "node:stream";
^
3: import { TSR_SCRIPT_BARRIER_ID } from "./constants.js";
4: function transformReadableStreamWithRouter(router, routerStream) {

at getRollupError (file:///Users/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/parseAst.js:401:41)
at error (file:///Users/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/parseAst.js:397:42)
at Module.error (file:///Users/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:16956:16)
at Module.traceVariable (file:///Users/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:17412:29)
at ModuleScope.findVariable (file:///Users/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:15076:39)
at FunctionScope.findVariable (file:///Users/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:5649:38)
at FunctionBodyScope.findVariable (file:///Users/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:5649:38)
at MemberExpression.bind (file:///Users/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:7363:49)
at CallExpression.bind (file:///Users/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:2813:23)
at CallExpression.bind (file:///Users/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:12123:15)

 ELIFECYCLE  Command failed with exit code 1.

It seems like you import the nodejs code in the browser side.

<!-- gh-comment-id:3775281281 --> @himself65 commented on GitHub (Jan 20, 2026): > [@bytaesu](https://github.com/bytaesu) (sorry for the ping) It seems like this issue got introduced again with the latest versions of the packages (tanstack + better auth). Once i comment out the `tanstackStartCookies` import and plugin in the createAuthClient my build passes otherwise i get this: > > vite v7.3.1 building client environment for production... > [plugin vite:resolve] Module "node:async_hooks" has been externalized for browser compatibility, imported by "/Users/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/@tanstack+start-server-core@1.153.2_crossws@0.4.1_srvx@0.9.6_/node_modules/@tanstack/start-server-core/dist/esm/request-response.js". See https://vite.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details. > [plugin vite:resolve] Module "node:stream/web" has been externalized for browser compatibility, imported by "/Users/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/@tanstack+router-core@1.153.2/node_modules/@tanstack/router-core/dist/esm/ssr/transformStreamWithRouter.js". See https://vite.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details. > [plugin vite:resolve] Module "node:stream" has been externalized for browser compatibility, imported by "/Users/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/@tanstack+router-core@1.153.2/node_modules/@tanstack/router-core/dist/esm/ssr/transformStreamWithRouter.js". See https://vite.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details. > [plugin vite:resolve] Module "node:stream" has been externalized for browser compatibility, imported by "/Users/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/@tanstack+react-router@1.153.2_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@tanstack/react-router/dist/esm/ssr/renderRouterToStream.js". 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/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/@tanstack+start-storage-context@1.153.2/node_modules/@tanstack/start-storage-context/dist/esm/async-local-storage.js". See https://vite.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details. > ✓ 4331 modules transformed. > ✗ Build failed in 3.62s > error during build: > node_modules/.pnpm/@tanstack+router-core@1.153.2/node_modules/@tanstack/router-core/dist/esm/ssr/transformStreamWithRouter.js (2:9): "Readable" is not exported by "__vite-browser-external", imported by "node_modules/.pnpm/@tanstack+router-core@1.153.2/node_modules/@tanstack/router-core/dist/esm/ssr/transformStreamWithRouter.js". > file: /Users/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/@tanstack+router-core@1.153.2/node_modules/@tanstack/router-core/dist/esm/ssr/transformStreamWithRouter.js:2:9 > > 1: import { ReadableStream } from "node:stream/web"; > 2: import { Readable } from "node:stream"; > ^ > 3: import { TSR_SCRIPT_BARRIER_ID } from "./constants.js"; > 4: function transformReadableStreamWithRouter(router, routerStream) { > > at getRollupError (file:///Users/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/parseAst.js:401:41) > at error (file:///Users/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/parseAst.js:397:42) > at Module.error (file:///Users/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:16956:16) > at Module.traceVariable (file:///Users/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:17412:29) > at ModuleScope.findVariable (file:///Users/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:15076:39) > at FunctionScope.findVariable (file:///Users/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:5649:38) > at FunctionBodyScope.findVariable (file:///Users/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:5649:38) > at MemberExpression.bind (file:///Users/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:7363:49) > at CallExpression.bind (file:///Users/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:2813:23) > at CallExpression.bind (file:///Users/josippapez/Desktop/brisk-fit-web-static/node_modules/.pnpm/rollup@4.53.3/node_modules/rollup/dist/es/shared/node-entry.js:12123:15) >  ELIFECYCLE  Command failed with exit code 1. It seems like you import the nodejs code in the browser side.
Author
Owner

@josippapez commented on GitHub (Jan 20, 2026):

It does seem like but i don't use any of the said imports on my side. The issue get's resolved once i comment out the said plugin

<!-- gh-comment-id:3775283529 --> @josippapez commented on GitHub (Jan 20, 2026): It does seem like but i don't use any of the said imports on my side. The issue get's resolved once i comment out the said plugin
Author
Owner

@himself65 commented on GitHub (Jan 20, 2026):

You shouldn't import tanstackStartCookie on the client side.

<!-- gh-comment-id:3775289008 --> @himself65 commented on GitHub (Jan 20, 2026): You shouldn't import `tanstackStartCookie` on the client side.
Author
Owner

@josippapez commented on GitHub (Jan 20, 2026):

You shouldn't import tanstackStartCookie on the client side.

Okay then, as i first understood this that it was needed to handle the automatic handle of cookies for the auth and that without it i would need to do it manually. But if the cookies are handled (set) automatically regardless of that plugin and that plugin is only for the auth through tanstack start api route then it's all good an thanks for clearing up the confusion.

<!-- gh-comment-id:3775308465 --> @josippapez commented on GitHub (Jan 20, 2026): > You shouldn't import `tanstackStartCookie` on the client side. Okay then, as i first understood this that it was needed to handle the automatic handle of cookies for the auth and that without it i would need to do it manually. But if the cookies are handled (set) automatically regardless of that plugin and that plugin is only for the auth through tanstack start api route then it's all good an thanks for clearing up the confusion.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#19430