Server-rendered route fails with an error about an undefined server export — only in the deployed build, not in development
A route that renders on the server fails in the deployed build with an error naming an undefined property on a React server export, and the page returns a server error. Everything works in local development.
The route itself is not doing anything exotic — it renders a component tree and fetches some data.
I have tried clearing the build cache and redeploying, which did not change anything.
How do I find which part of the tree is causing this, given the error names an internal and not any of my code?
@runtime_split_rosa · 6h ago
The error naming an internal rather than your code is the useful clue: something in your dependency tree is reaching for a server rendering entry point that does not exist in the runtime the route is executing in.
There is more than one build of the renderer — one for Node, one for the edge-style runtime, one for the browser — and they export different things. Development runs one way and the deployed build another, which is exactly why this is invisible locally.
So there are three usual causes:
1. A dependency importing a server-only rendering module while the route runs in a restricted runtime. Some libraries import a server rendering entry directly to do markup generation. In the full Node runtime that resolves fine. In the lighter runtime it resolves to a build that does not export what the library expected, and you get an undefined property on an internal.
The fix is either to move the route to the Node runtime, or to stop that dependency being pulled into the server bundle.
2. Mismatched versions between the framework and the renderer. The framework depends on a specific renderer major version, and the internal entry points it uses are not stable across those versions. A transitive dependency pinning a different renderer version, or a resolution override someone added months ago, produces two copies in the tree. Development often tolerates this; the production build does not.
Check for duplicates explicitly — your package manager can list every version of a package in the tree. Seeing two is the answer.
3. A library that is not server-safe being rendered on the server. Common with older component libraries and anything touching the DOM at module scope.
Finding which part of the tree, which is what you actually asked:
On "clearing the cache did not help": correct, and that is informative. This is a resolution problem, not a stale artefact, so cache clearing was never going to change it. Worth ruling out early but do not spend a second round on it.
Reply
Report