{"record":{"id":"82c20ea1b0fafb76","repo":"facebook/react","slug":"the-react-server-cannot-be-used-outside-a-react-se-82c20e","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-turbopack/static.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-turbopack/static.js#L1-L14","documentation":"react-server-dom-turbopack/static.js is the fallback entry Node resolves when the react-server export condition is NOT active. React's server bundles depend on that condition to swap in the react-server build of react (the one whose client APIs throw); loading the server/static writer without it would pull in the wrong react, so the module throws immediately at import time with the fix in the message.","triggerScenarios":"Importing react-server-dom-turbopack/static (or /server, which re-exports it) in a Node process that was started without `--conditions react-server`, e.g. `node server.js`, a custom server script, or a test runner with default export conditions.","commonSituations":"Custom Node servers or SSR scripts run without the flag; vitest/jest resolving the package with default conditions; tools that spawn node without forwarding NODE_OPTIONS; upgrading a setup where the flag used to be set in a now-ignored env file.","solutions":["Start Node with the condition: `node --conditions react-server server.js` (or add it to NODE_OPTIONS / your start script).","For jest set `customExportConditions: ['react-server']` in react-server test environments; for vitest add `resolve.conditions: ['react-server']` in the server project config.","Ensure bundlers that resolve the server bundle (webpack/turbopack for the server) include 'react-server' in resolve conditions.","Verify with `node -p \"process.execArgv\"` that the flag actually reaches the process that imports the package."],"exampleFix":"// before\n\"scripts\": { \"start\": \"node server.js\" }\n\n// after\n\"scripts\": { \"start\": \"node --conditions react-server server.js\" }","handlingStrategy":"validation","validationCode":"// Check before importing the server entry\nconst hasReactServerCondition =\n  process.execArgv.some(a => a.includes('react-server')) ||\n  (process.env.NODE_OPTIONS || '').includes('react-server');\nif (!hasReactServerCondition) {\n  throw new Error('Start Node with --conditions react-server before loading the Flight server');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Bake `node --conditions react-server` into start scripts and Docker ENTRYPOINT.","Set NODE_OPTIONS='--conditions react-server' so child processes inherit the flag.","In tests, configure customExportConditions/resolve.conditions instead of relying on defaults."],"tags":["rsc","react-server-components","node","export-conditions","environment","turbopack"],"backgroundTag":"missing-react-server-condition","analyzedSha":"eafeac097ba51e1eab809c07102126bd5f8e5425","analyzedAt":"2026-08-21T22:01:08.818Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}