facebook/react · 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-esm/npm/static.js is the default-condition stub for the /static subpath (the static-generation/prerender API) in the published package. Identically to the server stub, the real implementation only resolves when the 'react-server' export condition is active; without it Node picks this stub, which throws and instructs you to enable --conditions react-server.
Source
Thrown at packages/react-server-dom-esm/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
- Run the process with node --conditions react-server
- Add 'react-server' to the resolve conditions of every build entry that imports the static API
- In Jest, use NODE_OPTIONS='--conditions react-server' or moduleNameMapper pointing at the .react-server.js artifact
Example fix
# before $ node prerender.js # importing react-server-dom-esm/static -> throws # after $ node --conditions react-server prerender.js
Defensive patterns
Strategy: validation
Validate before calling
if (!process.execArgv.some(a => a.includes('react-server'))) {
throw new Error('Start this process with: node --conditions react-server');
} Prevention
- Run static-generation scripts with the same node --conditions react-server flag as the main server
- Configure every build entry that touches /static with the react-server resolve condition
- Document the flag in the repo README so CI and local runs match
When it happens
Trigger: Importing 'react-server-dom-esm/static' (e.g. for the static RSC APIs) in a Node process without --conditions react-server; bundler/test-runner resolution that ignores custom export conditions and falls through to the stub.
Common situations: Static-site generation scripts started without the condition flag; build configs where only the server bundle got resolve.conditions but a second entry (prerender worker) did not.
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
- The React Server Writer cannot be used outside a react-serve
- 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/0bca7d9333321d5f.
Report an issue: GitHub.