facebook/react · error · Error
The React Server cannot be used outside a react-server envir
Error message
The React Server cannot be used outside a react-server environment. You must configure Node.js using the `--conditions react-server` flag.
What it means
The source-level server entry of react-server-dom-unbundled throws unless Node resolves it under the react-server export condition. The package's exports map points the condition at the real server implementation; without the condition you get this stub, because running the Flight server on the client-conditioned react build would break serialization invariants.
Source
Thrown at packages/react-server-dom-unbundled/server.js:10
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
throw new Error(
'The React Server cannot be used outside a react-server environment. ' +
'You must configure Node.js using the `--conditions react-server` flag.',
);
View on GitHub (pinned to eafeac097b)
Solutions
- Launch with `node --conditions react-server --import ./node-register.js server.js` (or equivalent with the condition flag).
- Add 'react-server' to your test runner's export conditions.
- Keep the flag in NODE_OPTIONS so spawned workers inherit it.
- Sanity-check with `node -p "process.execArgv.join(' ')"` inside the failing process.
Example fix
# before node --import ./register.js server.js # after node --conditions react-server --import ./register.js server.js
Defensive patterns
Strategy: validation
Validate before calling
// Fail fast before registering the hook
if (!process.execArgv.some(a => a.includes('react-server')) && !(process.env.NODE_OPTIONS || '').includes('react-server')) {
console.error('Missing --conditions react-server; the Flight server stub will throw.');
process.exit(1);
} Prevention
- Use one npm script (with the flag) as the only entry point to the server.
- Assert the condition at process start instead of discovering the stub error deep in a request.
When it happens
Trigger: `import 'react-server-dom-unbundled/server'` (or the register hook that loads it) in a Node process launched without `--conditions react-server`.
Common situations: Bare `node server.js` for an RSC app; test runners with default conditions; scripts that register the unbundled node-register hook without the flag; environments where NODE_OPTIONS is stripped.
Related errors
- The React Server Writer cannot be used outside a react-serve
- The React Server cannot be used outside a react-server envir
- The React Server Writer cannot be used outside a react-serve
- The React Server Writer cannot be used outside a react-serve
- The React Server cannot be used outside a react-server envir
AI-assisted analysis of facebook/react@eafeac097b (2026-08-21).
Data as JSON: /api/errors/bbeca0513fd485bf.
Report an issue: GitHub.