{"record":{"id":"9a9e199b2c23bb0c","repo":"facebook/react","slug":"the-react-server-writer-cannot-be-used-outside-a-r-9a9e19","errorCode":null,"errorMessage":"The React Server Writer cannot be used outside a react-server environment. You must configure Node.js using the `--conditions react-server` flag.","messagePattern":"The React Server Writer 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/npm/static.js","lineNumber":3,"sourceCode":"'use strict';\n\nthrow new Error(\n  'The React Server Writer 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":7,"githubUrl":"https://github.com/facebook/react/blob/eafeac097ba51e1eab809c07102126bd5f8e5425/packages/react-server-dom-unbundled/npm/static.js#L1-L7","documentation":"npm/static.js is the condition-less fallback for the static-rendering entry of react-server-dom-unbundled. Static generation uses the same Flight writer as streaming SSR and equally requires the react-server environment; when the condition is missing, Node resolves to this stub which throws immediately with the required flag rather than rendering with the wrong react build.","triggerScenarios":"Importing react-server-dom-unbundled/static (e.g. renderToReadableStream for static/prerender use) in Node without `--conditions react-server`.","commonSituations":"Prerender scripts or static-site generation CLIs run with plain `node`; build tooling that spawns Node without forwarding NODE_OPTIONS; test setups with default conditions.","solutions":["Start the static-rendering process with `node --conditions react-server script.js`.","Add the condition to bundler/resolve config when the static entry is bundled at build time.","For tests, add 'react-server' to the runner's export conditions.","Verify process.execArgv in the failing process to confirm the flag is present."],"exampleFix":"# before\n\"build\": \"node prerender.js\"\n\n# after\n\"build\": \"node --conditions react-server prerender.js\"","handlingStrategy":"validation","validationCode":"if (!process.execArgv.some(a => a.includes('react-server'))) {\n  throw new Error('Static rendering requires: node --conditions react-server');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep prerender/static scripts and the dev server on the same Node flags.","Verify flags in build scripts with a startup assertion.","Include the condition in bundler resolve config when the static entry is bundled."],"tags":["rsc","react-server-components","unbundled","static-rendering","node","export-conditions"],"backgroundTag":"missing-react-server-condition","analyzedSha":"eafeac097ba51e1eab809c07102126bd5f8e5425","analyzedAt":"2026-08-21T22:01:08.818Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}