{"record":{"id":"1538bde054c6a560","repo":"facebook/react","slug":"the-react-server-writer-cannot-be-used-outside-a-r-1538bd","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-webpack/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-webpack/npm/server.js#L1-L7","documentation":"The published server entry (npm/server.js) is the non-react-server fallback for './server': the exports map only serves the real server implementation when the 'react-server' condition is active. This copy targets the Writer APIs, so its message says 'React Server Writer' — importing it without the condition throws immediately, telling you Node was not configured for the server environment.","triggerScenarios":"require/import of react-server-dom-webpack/server in Node without --conditions react-server; bundling the server entry with a bundler whose resolve conditions omit 'react-server'.","commonSituations":"node server.js run scripts missing the condition flag | Bundlers (webpack/esbuild/vite SSR) without conditionNames including 'react-server' | CI or production runners that strip NODE_OPTIONS","solutions":["Run Node with --conditions react-server (scripts entry: \"start\": \"node --conditions react-server server.js\")","Add 'react-server' to the server bundler's resolve.conditionNames / esbuild conditions","Verify NODE_OPTIONS propagates in CI, Docker CMD, and process managers"],"exampleFix":"# before\nCMD [\"node\", \"server.js\"]\n\n# after\nCMD [\"node\", \"--conditions\", \"react-server\", \"server.js\"]","handlingStrategy":"validation","validationCode":"const ok = process.execArgv.join(' ').includes('react-server') ||\n  (process.env.NODE_OPTIONS || '').includes('--conditions react-server');\nif (!ok) process.exitCode = 1; // refuse to boot without the condition","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Put the flag in package.json scripts, Dockerfile CMD, and CI env alike","Assert the condition early in server bootstrap and log a fix hint","Verify process managers (pm2/systemd) preserve NODE_OPTIONS"],"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"}