{"record":{"id":"ba92890418215206","repo":"facebook/react","slug":"the-react-server-writer-cannot-be-used-outside-a-r-ba9289","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-parcel/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-parcel/npm/server.js#L1-L7","documentation":"npm/server.js is the non-react-server fallback of the './server' export. It evaluates to a throw so the Flight writer never runs outside a process resolved with the react-server condition; the real implementation sits behind the condition in package.json exports.","triggerScenarios":"Importing 'react-server-dom-parcel/server' in a Node process started without --conditions react-server; a bundler resolving the default condition for a server entry; running the npm build under a runtime that does not forward Node conditions.","commonSituations":"Forgetting the flag in scripts or PM2/systemd configs; serverless bundlers that inline the server entry without react-server in conditionNames; jest/custom runners ignoring conditions.","solutions":["Run Node with --conditions react-server or set NODE_OPTIONS=--conditions react-server","Import the explicit 'react-server-dom-parcel/server.node' / 'server.edge' / 'server.browser' entry that bypasses the gate","Ensure your bundler resolves the server build with react-server in conditionNames"],"exampleFix":"// before\nnode server.mjs // imports 'react-server-dom-parcel/server' -> throws\n\n// after\nnode --conditions react-server server.mjs","handlingStrategy":"validation","validationCode":"const flags = process.execArgv.concat((process.env.NODE_OPTIONS || '').split(' '));\nif (!flags.some(a => a.includes('react-server'))) {\n  throw new Error('Start with --conditions react-server before loading react-server-dom-parcel/server');\n}","typeGuard":null,"tryCatchPattern":"try {\n  const server = await import('react-server-dom-parcel/server');\n} catch (e) {\n  if (/react-server environment/.test(e.message)) {\n    throw new Error('Restart with --conditions react-server');\n  }\n  throw e;\n}","preventionTips":["Add --conditions react-server to all server start scripts and PM2/systemd units","Verify bundler conditionNames include react-server for server bundles only","Smoke-test the built server artifact in CI with the same flags"],"tags":["react-server","conditions","node","package-exports","parcel"],"backgroundTag":"missing-react-server-condition","analyzedSha":"eafeac097ba51e1eab809c07102126bd5f8e5425","analyzedAt":"2026-08-21T22:01:08.818Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}