{"record":{"id":"0ef5efb718c95f58","repo":"facebook/react","slug":"the-react-server-cannot-be-used-outside-a-react-se-0ef5ef","errorCode":null,"errorMessage":"The React Server cannot be used outside a react-server environment. You must configure Node.js using the `--conditions react-server` flag.","messagePattern":"The React Server 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/server.js","lineNumber":10,"sourceCode":"/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * @flow\n */\n\nthrow new Error(\n  'The React Server 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":14,"githubUrl":"https://github.com/facebook/react/blob/eafeac097ba51e1eab809c07102126bd5f8e5425/packages/react-server-dom-parcel/server.js#L1-L14","documentation":"The source-form guard for the './server' entry: the exports map maps 'react-server-dom-parcel/server' to the real writer only under the react-server condition; every other resolution lands on this file, which throws on import with instructions to run Node with --conditions react-server.","triggerScenarios":"import ... from 'react-server-dom-parcel/server' evaluated without the react-server Node condition active — plain node, a bundler whose conditionNames omit it, or a runner (jest/vitest) that resolves conditions differently.","commonSituations":"Missing the flag in start scripts; test configs without customExportConditions/conditions; bundling server code with client condition sets.","solutions":["Run with node --conditions react-server (or NODE_OPTIONS)","Configure your test runner to resolve with the react-server condition for server-side tests","Or target the explicit .node/.edge/.browser subpath variants directly"],"exampleFix":"// before\n\"scripts\": { \"start\": \"node server.mjs\" }\n\n// after\n\"scripts\": { \"start\": \"node --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":["Keep the flag in every npm script that imports the server entry","Configure jest/vitest to resolve with the react-server condition for server tests","Fail fast at boot with the flag check instead of at first import"],"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-22T04:17:13.399Z"}