{"record":{"id":"0bca7d9333321d5f","repo":"facebook/react","slug":"the-react-server-writer-cannot-be-used-outside-a-r-0bca7d","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":null,"httpStatus":null,"severity":"error","filePath":"packages/react-server-dom-esm/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-esm/npm/static.js#L1-L7","documentation":"react-server-dom-esm/npm/static.js is the default-condition stub for the /static subpath (the static-generation/prerender API) in the published package. Identically to the server stub, the real implementation only resolves when the 'react-server' export condition is active; without it Node picks this stub, which throws and instructs you to enable --conditions react-server.","triggerScenarios":"Importing 'react-server-dom-esm/static' (e.g. for the static RSC APIs) in a Node process without --conditions react-server; bundler/test-runner resolution that ignores custom export conditions and falls through to the stub.","commonSituations":"Static-site generation scripts started without the condition flag; build configs where only the server bundle got resolve.conditions but a second entry (prerender worker) did not.","solutions":["Run the process with node --conditions react-server","Add 'react-server' to the resolve conditions of every build entry that imports the static API","In Jest, use NODE_OPTIONS='--conditions react-server' or moduleNameMapper pointing at the .react-server.js artifact"],"exampleFix":"# before\n$ node prerender.js # importing react-server-dom-esm/static -> throws\n\n# after\n$ node --conditions react-server prerender.js","handlingStrategy":"validation","validationCode":"if (!process.execArgv.some(a => a.includes('react-server'))) {\n  throw new Error('Start this process with: node --conditions react-server');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run static-generation scripts with the same node --conditions react-server flag as the main server","Configure every build entry that touches /static with the react-server resolve condition","Document the flag in the repo README so CI and local runs match"],"tags":["react-server-components","node","export-conditions","static-generation"],"backgroundTag":"missing-react-server-condition","analyzedSha":"eafeac097ba51e1eab809c07102126bd5f8e5425","analyzedAt":"2026-08-21T22:01:08.818Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}