facebook/react · error · 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
npm/server.js is the non-react-server fallback of the './server' export. It evaluates to a throw so the Flight writer never runs outside a process resolved with the react-server condition; the real implementation sits behind the condition in package.json exports.
Source
Thrown at packages/react-server-dom-parcel/npm/server.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 Node with --conditions react-server or set NODE_OPTIONS=--conditions react-server
- Import the explicit 'react-server-dom-parcel/server.node' / 'server.edge' / 'server.browser' entry that bypasses the gate
- Ensure your bundler resolves the server build with react-server in conditionNames
Example fix
// before node server.mjs // imports 'react-server-dom-parcel/server' -> throws // after node --conditions react-server server.mjs
Defensive patterns
Strategy: validation
Validate before calling
const flags = process.execArgv.concat((process.env.NODE_OPTIONS || '').split(' '));
if (!flags.some(a => a.includes('react-server'))) {
throw new Error('Start with --conditions react-server before loading react-server-dom-parcel/server');
} Try / catch
try {
const server = await import('react-server-dom-parcel/server');
} catch (e) {
if (/react-server environment/.test(e.message)) {
throw new Error('Restart with --conditions react-server');
}
throw e;
} Prevention
- Add --conditions react-server to all server start scripts and PM2/systemd units
- Verify bundler conditionNames include react-server for server bundles only
- Smoke-test the built server artifact in CI with the same flags
When it happens
Trigger: Importing 'react-server-dom-parcel/server' in a Node process started without --conditions react-server; a bundler resolving the default condition for a server entry; running the npm build under a runtime that does not forward Node conditions.
Common situations: Forgetting the flag in scripts or PM2/systemd configs; serverless bundlers that inline the server entry without react-server in conditionNames; jest/custom runners ignoring conditions.
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 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/ba92890418215206.
Report an issue: GitHub.