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
react-server-dom-webpack/static.js is the fallback './static' entry that throws unless the 'react-server' export condition is active. It guards the static Flight writer so that a mis-configured environment (plain Node, browser, or a bundler without the condition) fails at import time with the exact flag needed, rather than loading server-only code into the wrong runtime.
Source
Thrown at packages/react-server-dom-webpack/static.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
- Start the process with node --conditions react-server
- Add 'react-server' to resolve.conditionNames (webpack), conditions (esbuild/vite ssr), or test runner export conditions
- Double-check NODE_OPTIONS is present where the import actually executes (containers, cron, process managers)
Example fix
// before
"scripts": {"start": "node server.js"}
// after
"scripts": {"start": "node --conditions react-server server.js"} Defensive patterns
Strategy: validation
Validate before calling
if (!(process.execArgv.join(' ') + ' ' + (process.env.NODE_OPTIONS || '')).includes('react-server')) {
console.error('fix: node --conditions react-server');
process.exit(1);
} Prevention
- Centralize the node start command; do not hand-type it per environment
- Include the condition in test, dev, and prod commands identically
- CI should run the server entry once as a smoke test
When it happens
Trigger: Importing react-server-dom-webpack/static in any context where the resolver did not apply the 'react-server' condition (plain node, browser bundle, tests).
Common situations: Following RSC demos that use /static without copying the start script's --conditions react-server flag | Tooling (ts-node,tsx, vitest) that resolves exports with default conditions only | Monorepo task runners dropping NODE_OPTIONS
Related errors
- 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 cannot be used outside a react-server envir
- The React Server cannot be used outside a react-server envir
- The React Server Writer cannot be used outside a react-serve
AI-assisted analysis of facebook/react@eafeac097b (2026-08-21).
Data as JSON: /api/errors/17af201006d2aba9.
Report an issue: GitHub.