{"record":{"id":"178bfa8a4ca0b6d7","repo":"facebook/react","slug":"the-react-server-cannot-be-used-outside-a-react-se","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":null,"httpStatus":null,"severity":"error","filePath":"packages/react-server-dom-esm/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-esm/server.js#L1-L14","documentation":"The source-level server entry of react-server-dom-esm: importing the server module outside a react-server environment throws at module load. The server writer only resolves under the 'react-server' export condition; in any other condition the module graph intentionally fails fast with instructions to configure Node with --conditions react-server. This keeps server-only code from ever executing in a client bundle or plain Node process.","triggerScenarios":"importing 'react-server-dom-esm/server' (renderToPipeableStream and friends) in plain Node without the react-server condition; a client bundle graph that transitively reaches the server entry; tooling (bundler, test runner) resolving without custom conditions so the throwing module is selected.","commonSituations":"RSC servers started without the documented flag; shared modules imported by both client and server where the server import leaks into the client graph; CI running server code through runners that reset NODE_OPTIONS.","solutions":["Start the server with node --conditions react-server","Add 'react-server' to resolve conditions for the server build, and ensure the client build never imports the server entry","For Jest, set NODE_OPTIONS='--conditions react-server' for server-side test projects","Split shared code so the server entry is only reachable from server-only modules"],"exampleFix":"// before\n// package.json\n\"scripts\": { \"start\": \"node server.js\" }\n\n// after\n\"scripts\": { \"start\": \"node --conditions react-server server.js\" }","handlingStrategy":"validation","validationCode":"const hasReactServerCondition =\n  process.execArgv.some(a => a.includes('react-server'));\nif (!hasReactServerCondition) {\n  console.error('Run with: node --conditions react-server');\n  process.exit(1);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Put node --conditions react-server in the package.json start script","Keep server-only imports in files only the server graph can reach","Set NODE_OPTIONS='--conditions react-server' for server-side jest projects"],"tags":["react-server-components","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"}