{"record":{"id":"70a7c056cea6c55b","repo":"facebook/react","slug":"the-react-server-writer-cannot-be-used-outside-a-r-70a7c0","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/server.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/server.js#L1-L7","documentation":"npm/server.js of react-server-dom-unbundled is what Node loads when the server entry is resolved WITHOUT the react-server export condition. The Flight server writer depends on the react-server build of react for correct semantics, so instead of silently using the wrong react it throws at import time with the required Node flag.","triggerScenarios":"`import ... from 'react-server-dom-unbundled/server'` executed in a Node process without `--conditions react-server` (plain `node script.js`, default test-runner resolution).","commonSituations":"Running an RSC server or unit tests without the condition flag; NODE_OPTIONS not propagated to child processes; framework upgrades that dropped the flag from start scripts.","solutions":["Run Node with the flag: `node --conditions react-server server.js`.","Configure test runners: jest `customExportConditions: ['node', 'react-server']`, vitest `resolve.conditions` including 'react-server'.","Put the flag in NODE_OPTIONS if child processes import the server entry.","Confirm resolution with `node --conditions react-server -e \"console.log(require.resolve('react-server-dom-unbundled/server'))\"`."],"exampleFix":"# before\nnode server.js\n\n# after\nnode --conditions react-server server.js","handlingStrategy":"validation","validationCode":"if (!process.execArgv.some(a => a.includes('react-server'))) {\n  throw new Error('Run with: node --conditions react-server');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Add --conditions react-server to every script that imports the server entry.","Propagate NODE_OPTIONS to spawned workers.","Document the flag in the repo README so operators copy correct start commands."],"tags":["rsc","react-server-components","unbundled","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"}