{"record":{"id":"2e3e0d98b3384f39","repo":"facebook/react","slug":"the-react-server-cannot-be-used-outside-a-react-se-2e3e0d","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/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-unbundled/static.js#L1-L14","documentation":"react-server-dom-unbundled/static.js is the fallback entry for the package's './static' export when the 'react-server' Node condition is NOT active (see the exports map: './static' only resolves to real code under react-server). It exists so that accidentally importing the server/static runtime in an ordinary Node process fails immediately with instructions instead of mysteriously misbehaving.","triggerScenarios":"require/import of react-server-dom-unbundled/static (or an export path that falls through to it) in a Node process started without --conditions react-server; bundling server code without adding 'react-server' to the bundler's resolve conditions.","commonSituations":"Running node server.js, tests, or scripts that touch the server entry without the condition flag | Jest/vitest configs missing customExportConditions/conditions with 'react-server' | Webpack esbuild configs missing conditionNames: ['react-server'] for the server bundle","solutions":["Start Node with the flag: node --conditions react-server server.js (or set NODE_OPTIONS='--conditions react-server')","Add 'react-server' to your test runner conditions (jest: testEnvironmentOptions.customExportConditions) and to the server bundler's resolve.conditionNames","Import the client entry instead if this file is actually client-side code"],"exampleFix":"# before\nnode server.js\n\n# after\nnode --conditions react-server server.js","handlingStrategy":"validation","validationCode":"// Fail with a clear message before the bad import happens\nconst hasCondition = process.execArgv.some(a => a.includes('react-server')) ||\n  (process.env.NODE_OPTIONS || '').includes('react-server');\nif (!hasCondition) throw new Error('start with: node --conditions react-server');\nconst rscStatic = await import('react-server-dom-unbundled/static');","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Bake --conditions react-server into npm start scripts and Docker CMDs","Add 'react-server' to jest customExportConditions and bundler conditionNames","Smoke-test the server entry in CI with the exact start command"],"tags":["react-server-components","node","package-exports","conditions"],"backgroundTag":"missing-react-server-condition","analyzedSha":"eafeac097ba51e1eab809c07102126bd5f8e5425","analyzedAt":"2026-08-21T22:01:08.818Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}