{"record":{"id":"bbeca0513fd485bf","repo":"facebook/react","slug":"the-react-server-cannot-be-used-outside-a-react-se-bbeca0","errorCode":null,"errorMessage":"The React Server cannot be used outside a react-server environment. You must configure Node.js using the `--conditions react-server` flag.","messagePattern":"The React Server cannot be used outside a react-server environment\\. You must configure Node\\.js using the `--conditions react-server` flag\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/react-server-dom-unbundled/server.js","lineNumber":10,"sourceCode":"/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * @flow\n */\n\nthrow new Error(\n  'The React Server cannot be used outside a react-server environment. ' +\n    'You must configure Node.js using the `--conditions react-server` flag.',\n);\n","sourceCodeStart":1,"sourceCodeEnd":14,"githubUrl":"https://github.com/facebook/react/blob/eafeac097ba51e1eab809c07102126bd5f8e5425/packages/react-server-dom-unbundled/server.js#L1-L14","documentation":"The source-level server entry of react-server-dom-unbundled throws unless Node resolves it under the react-server export condition. The package's exports map points the condition at the real server implementation; without the condition you get this stub, because running the Flight server on the client-conditioned react build would break serialization invariants.","triggerScenarios":"`import 'react-server-dom-unbundled/server'` (or the register hook that loads it) in a Node process launched without `--conditions react-server`.","commonSituations":"Bare `node server.js` for an RSC app; test runners with default conditions; scripts that register the unbundled node-register hook without the flag; environments where NODE_OPTIONS is stripped.","solutions":["Launch with `node --conditions react-server --import ./node-register.js server.js` (or equivalent with the condition flag).","Add 'react-server' to your test runner's export conditions.","Keep the flag in NODE_OPTIONS so spawned workers inherit it.","Sanity-check with `node -p \"process.execArgv.join(' ')\"` inside the failing process."],"exampleFix":"# before\nnode --import ./register.js server.js\n\n# after\nnode --conditions react-server --import ./register.js server.js","handlingStrategy":"validation","validationCode":"// Fail fast before registering the hook\nif (!process.execArgv.some(a => a.includes('react-server')) && !(process.env.NODE_OPTIONS || '').includes('react-server')) {\n  console.error('Missing --conditions react-server; the Flight server stub will throw.');\n  process.exit(1);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use one npm script (with the flag) as the only entry point to the server.","Assert the condition at process start instead of discovering the stub error deep in a request."],"tags":["rsc","react-server-components","unbundled","node","export-conditions","environment"],"backgroundTag":"missing-react-server-condition","analyzedSha":"eafeac097ba51e1eab809c07102126bd5f8e5425","analyzedAt":"2026-08-21T22:01:08.818Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}