Repository navigation
Could not resolve "#tanstack-router-entry" #5795
Description
Which project does this relate to?
Start
Describe the bug
I'm out of town this weekend but was running into this so wanted to file this bug report sooner than later.
I'm using alchemy, which wraps cloudflare-vite to run tanstack start. I haven't had time to create a clean reproduction but basically what seems to be happening, is that my auth service is created as an Effect.Service from effect-ts. One of the other deps coming is is my Drizzle postgres client from '@effect/sql-drizzle/Pg'.
As soon as i import import { auth } from '@repo/core/auth/handler' into server.ts or routes/api/auth/$.ts my app blows up with the error below. handler.ts imports my Runtime from effect, which has all my app dependencies, which some are required for some of the hooks that better auth calls in the Effectful Better Auth instance.
Possibly related to vitejs/vite#20867 (comment). I was seeing pre-bundling issues on later versions of vite.
The web app producing this error is a basic better-t-stack templated start app, with the only changes adding in alchemy and dropping in my auth into the server route. Everything starts up fine without the eventual better-auth dependency as described above.
Using vars defined in process.env
3:21:50 PM [vite] (client) Re-optimizing dependencies because lockfile has changed
VITE v7.0.0 ready in 1097 ms
➜ Local: http://localhost:5173/
➜ Network: use --host to expose
➜ Debug: http://localhost:5173/__debug
➜ press h + enter to show help
[updating] web Updating Resource...
[skipped] web > url Skipped Resource (no changes)
[updated] web Updated Resource
Web -> http://localhost:5173/
✘ [ERROR] Could not resolve "#tanstack-router-entry"
../../node_modules/.bun/@tanstack+start-server-core@1.134.15+b0d3c3aaff3e390a/node_modules/@tanstack/start-server-core/dist/esm/createStartHandler.js:29:33:
29 │ routerEntry = await import("#tanstack-router-entry");
╵ ~~~~~~~~~~~~~~~~~~~~~~~~
The package import "#tanstack-router-entry" is not defined in this "imports" map:
../../node_modules/.bun/@tanstack+start-server-core@1.134.15+b0d3c3aaff3e390a/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.
✘ [ERROR] Could not resolve "#tanstack-start-entry"
../../node_modules/.bun/@tanstack+start-server-core@1.134.15+b0d3c3aaff3e390a/node_modules/@tanstack/start-server-core/dist/esm/createStartHandler.js:32:32:
32 │ startEntry = await import("#tanstack-start-entry");
╵ ~~~~~~~~~~~~~~~~~~~~~~~
The package import "#tanstack-start-entry" is not defined in this "imports" map:
../../node_modules/.bun/@tanstack+start-server-core@1.134.15+b0d3c3aaff3e390a/node_modules/@tanstack/start-server-core/package.json:49:13:
49 │ "imports": {
╵ ^
You can mark the path "#tanstack-start-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.
✘ [ERROR] Could not resolve "tanstack-start-manifest:v"
../../node_modules/.bun/@tanstack+start-server-core@1.134.15+b0d3c3aaff3e390a/node_modules/@tanstack/start-server-core/dist/esm/router-manifest.js:3:44:
3 │ ...t { tsrStartManifest } = await import("tanstack-start-manifest:v");
╵ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
You can mark the path "tanstack-start-manifest:v" 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.
✘ [ERROR] Could not resolve "tanstack-start-injected-head-scripts:v"
../../node_modules/.bun/@tanstack+start-server-core@1.134.15+b0d3c3aaff3e390a/node_modules/@tanstack/start-server-core/dist/esm/router-manifest.js:9:49:
9 │ ...Scripts } = await import("tanstack-start-injected-head-scripts:v");
╵ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You can mark the path "tanstack-start-injected-head-scripts:v" 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.
3:22:06 PM [vite] (ssr) error while updating dependencies:
Error: Build failed with 4 errors:
../../node_modules/.bun/@tanstack+start-server-core@1.134.15+b0d3c3aaff3e390a/node_modules/@tanstack/start-server-core/dist/esm/createStartHandler.js:29:33: ERROR: Could not resolve "#tanstack-router-entry"
../../node_modules/.bun/@tanstack+start-server-core@1.134.15+b0d3c3aaff3e390a/node_modules/@tanstack/start-server-core/dist/esm/createStartHandler.js:32:32: ERROR: Could not resolve "#tanstack-start-entry"
../../node_modules/.bun/@tanstack+start-server-core@1.134.15+b0d3c3aaff3e390a/node_modules/@tanstack/start-server-core/dist/esm/router-manifest.js:3:44: ERROR: Could not resolve "tanstack-start-manifest:v"
../../node_modules/.bun/@tanstack+start-server-core@1.134.15+b0d3c3aaff3e390a/node_modules/@tanstack/start-server-core/dist/esm/router-manifest.js:9:49: ERROR: Could not resolve "tanstack-start-injected-head-scripts:v"
at failureErrorWithLog (/Users/am/Coding/redacted-projects/redacted/node_modules/.bun/esbuild@0.25.12/node_modules/esbuild/lib/main.js:1467:15)
at /Users/am/Coding/redacted-projects/redacted/node_modules/.bun/esbuild@0.25.12/node_modules/esbuild/lib/main.js:926:25
at /Users/am/Coding/redacted-projects/redacted/node_modules/.bun/esbuild@0.25.12/node_modules/esbuild/lib/main.js:1345:9
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
3:22:06 PM [vite] Internal server error: There is a new version of the pre-bundle for "/Users/am/Coding/redacted-projects/redacted/apps/web/node_modules/.vite/deps_ssr/better-auth.js?v=93306dc9", a page reload is going to ask for it.
at CustomModuleRunner.cachedModule (workers/runner-worker.js:1236:20)
at request (workers/runner-worker.js:1154:83)
at null.<anonymous> (/Users/am/Coding/redacted-projects/redacted/packages/core/src/auth/setup.ts:4:1)
at Object.runInlinedModule (workers/runner-worker.js:1337:4)
at CustomModuleRunner.directRequest (workers/runner-worker.js:1208:59)
at CustomModuleRunner.cachedRequest (workers/runner-worker.js:1115:73)
at null.<anonymous> (/Users/am/Coding/redacted-projects/redacted/packages/core/src/auth/handler.ts:2:1)
at Object.runInlinedModule (workers/runner-worker.js:1337:4)
at CustomModuleRunner.directRequest (workers/runner-worker.js:1208:59)
at CustomModuleRunner.cachedRequest (workers/runner-worker.js:1115:73)
3:22:06 PM [vite] Internal server error: There is a new version of the pre-bundle for "/Users/am/Coding/redacted-projects/redacted/apps/web/node_modules/.vite/deps_ssr/better-auth.js?v=93306dc9", a page reload is going to ask for it.
at CustomModuleRunner.cachedModule (workers/runner-worker.js:1236:20)
at request (workers/runner-worker.js:1154:83)
at null.<anonymous> (/Users/am/Coding/redacted-projects/redacted/packages/core/src/auth/setup.ts:4:1)
at Object.runInlinedModule (workers/runner-worker.js:1337:4)
at CustomModuleRunner.directRequest (workers/runner-worker.js:1208:59)
at CustomModuleRunner.cachedRequest (workers/runner-worker.js:1115:73)
at null.<anonymous> (/Users/am/Coding/redacted-projects/redacted/packages/core/src/auth/handler.ts:2:1)
at Object.runInlinedModule (workers/runner-worker.js:1337:4)
at CustomModuleRunner.directRequest (workers/runner-worker.js:1208:59)
at CustomModuleRunner.cachedRequest (workers/runner-worker.js:1115:73)Your Example Website or App
N/A
Steps to Reproduce the Bug or Issue
see above
Expected behavior
no issues
Screenshots or Videos
No response
Platform
Vite 7.0.0
MacOS 15.6
Tanstack 1.134.15
Additional context
No response
Activity
schiller-manuel commentedon Nov 8, 2025
please share a full reproduction project
guillemus commentedon Nov 10, 2025
not op but I have the same error in this repo
https://github.com/guillemus/tanstack-mpa
This happened after I tried to add better auth. Maybe it is bc there's no entry-client / server files? That's what haiku suggested me but idk.
here's the full output:
guillemus commentedon Nov 10, 2025
@schiller-manuel I found what causes the issue somehow.
to reproduce:
bun devI hope this helps
austinm911 commentedon Nov 10, 2025
@guillemus Even adding the client/server.ts entry files, I run into the same issues as well
theoludwig commentedon Nov 11, 2025
I have the same issue but with Vitest.
schiller-manuel commentedon Nov 11, 2025
@theoludwig can you share a reproducer project with vitest?
theoludwig commentedon Nov 11, 2025
Sure, here it is: https://github.com/theoludwig/vite-nitro-issues/tree/vitest-issue
To reproduce:
git clone git@github.com:theoludwig/vite-nitro-issues.gitcd vite-nitro-issuesgit checkout vitest-issuepnpm install --frozen-lockfilenode --run testgianlazaro commentedon Nov 20, 2025
I'll see if I have time to make a reproducer sometime this week, but I'm having this exact issue when I install a specific library.
better-auth@beta (since 1.4 stable is coming out Friday)
rollsrobby commentedon Nov 20, 2025
I only see this issue if I enable the
reactStartCookieplugin by better-auth.And only after removing the node_modules folder and reinstalling(
pnpm install).If I remove the plugin, clean, install. All works fine.
Maybe this observation helps..
gianlazaro commentedon Nov 20, 2025
@rollsrobby That did the trick for me!
It got me curious and looked into what could possibly be making this issue.
I was able to reproduce the original poster's issue by using setCookie imported from "@tanstack/react-start/server" (used in certain cases). I hope this narrows it down for you, @schiller-manuel
update: I guess it's mostly affects improper uses of functions that should only run on the server like setting cookies, or headers that causes the error.
2bdelghafour commentedon Nov 20, 2025
@gianlazaro I ran into the same issue when using Better Auth with Tanstack Start and I can see there is already a PR open on their end to fix it by using the proper imports
better-auth/better-auth#6045
dotnize commentedon Nov 22, 2025
For better-auth users this has been fixed in
^1.4.1gianlazaro commentedon Nov 26, 2025
@dotnize @2bdelghafour
1.4.1 fixed the issue but 1.4.2 (released a couple of hours ago) reverts back to importing start-server-core because it apparently fixes the cookies issue on with solid on tanstack start.
We're back to the same issue.
better-auth/better-auth#6235
fix: temporarily lock to better-auth 1.4.1 (TanStack/router#5795 (com…
22 remaining items
temp: downgrade better-auth to 1.4.12 (TanStack/router#5795 (comment))
web-dev-sayantan commentedon Jan 16, 2026
Facing the same issue with @tanstack/* 1.150.0 and better-auth 1.4.13 in my repo,
Opus 4.5 went on a crazy run, and fixed it for now with bunch of weird config in vite.config.ts, half of which I don't understand.
ludusrusso commentedon Jan 16, 2026
same here
joshymcd commentedon Jan 16, 2026
I was just having this issue.
For me excluding my Tanstack packages from Vites dev server optimisations seemed to do the trick
williiam-tran commentedon Jan 17, 2026
This works for me!
kusalkalinga00 commentedon Jan 17, 2026
This worked for me also. Issue started to originate when I migrate from bun to pnpm.
rgripper commentedon Jan 17, 2026
didnt help, I still have the same error
astralarya commentedon Jan 17, 2026
I started getting similar errors upgrading from 1.149.1 -> 1.151.1, which I was able to resolve by adding this to my vite config:
On one hand, I'm glad that this fixes it, but on the other hand, I wish it weren't necessary.
bytaesu commentedon Jan 18, 2026
from Better Auth,
We've worked on this, I tested it in the actual app, and I can confirm that it's fixed now in
v1.4.15😄MarcusGasberg commentedon Jan 24, 2026
Weirdly enough I still encountered it after upgrading, when I tried to deploy to Cloudflare workers. The issue was due to having multiple environments in my wrangler.toml and not passing the correct CLOUDFLARE_ENV to my build command. I also had to point to the generated wrangler.json file.
Previous build command:
Fixed:
isc30 commentedon Feb 16, 2026
is this the properly-done-accepted way or just a hack?
isc30 commentedon Feb 19, 2026
For the proper solution, see better-auth/better-auth#6045 (comment)
Basically, replace the imports from
@tanstack/react-start-serverto@tanstack/react-start/serverand vite will be happy.I believe this would be a good addition to the eslint plugin, to inform users to use the proper import to avoid vite dependency optimization issues.
barbalex commentedon Feb 27, 2026
Not sure if this is the same issue: In an app using tanstack router I tried to use tanstack start (to add server routes). When replacing
TanStackRouterVite({ target: 'react', autoCodeSplitting: true })withtanstackStart()I immediately get this error:Bump dependencies (#35)
escwxyz commentedon May 4, 2026
Same error for basic start example with RSC, no better-auth, vite 8.
Repro: https://github.com/escwxyz/tanstack-rsc-test