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-form guard for the './server' entry: the exports map maps 'react-server-dom-parcel/server' to the real writer only under the react-server condition; every other resolution lands on this file, which throws on import with instructions to run Node with --conditions react-server.
Source
Thrown at packages/react-server-dom-parcel/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
- Run with node --conditions react-server (or NODE_OPTIONS)
- Configure your test runner to resolve with the react-server condition for server-side tests
- Or target the explicit .node/.edge/.browser subpath variants directly
Example fix
// before
"scripts": { "start": "node server.mjs" }
// after
"scripts": { "start": "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
- Keep the flag in every npm script that imports the server entry
- Configure jest/vitest to resolve with the react-server condition for server tests
- Fail fast at boot with the flag check instead of at first import
When it happens
Trigger: import ... from 'react-server-dom-parcel/server' evaluated without the react-server Node condition active — plain node, a bundler whose conditionNames omit it, or a runner (jest/vitest) that resolves conditions differently.
Common situations: Missing the flag in start scripts; test configs without customExportConditions/conditions; bundling server code with client condition sets.
Related errors
- 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
- 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/0ef5efb718c95f58.
Report an issue: GitHub.