facebook/react · critical · Error
The React Server Writer cannot be used outside a react-serve
Error message
The React Server Writer 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-turbopack/static (the Edge/static writer build) only resolves to a real implementation under the react-server export condition. Without that condition, this npm stub throws on import so the server-only Flight writer never executes in an unintended environment.
Source
Thrown at packages/react-server-dom-turbopack/npm/static.js:3
'use strict';
throw new Error(
'The React Server Writer 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
- Import the static writer only from modules conditionally loaded in the react-server branch
- Mirror the react-server condition in bundler/test configuration
Example fix
# before $ node server.js # import of react-server-dom-turbopack/static throws # after $ node --conditions react-server server.js
Defensive patterns
Strategy: validation
Validate before calling
const args = process.execArgv.join(' ');
if (!args.includes('react-server')) {
throw new Error('Static writer requires --conditions react-server');
}
const RSCStatic = require('react-server-dom-turbopack/static'); Prevention
- Start Edge-runtime processes in tests with the react-server condition too
- Load static writer entries only inside condition-gated branches
- Keep the flag in every script that can import server code
When it happens
Trigger: Importing react-server-dom-turbopack/static in a Node process without --conditions react-server, or resolving the conditionless fallback export from a client/bundler graph.
Common situations: Edge-runtime code executed under plain Node in tests; deploy scripts missing the condition flag; monorepos where the condition is set for the app but not for tooling.
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 cannot be used outside a react-server envir
- Use react-server-dom-turbopack/client instead.
- Use react-server-dom-turbopack/client instead.
AI-assisted analysis of facebook/react@eafeac097b (2026-08-21).
Data as JSON: /api/errors/a7e7881e5bb03f93.
Report an issue: GitHub.