{"record":{"id":"24ef1093abe09442","repo":"facebook/react","slug":"you-did-not-run-node-js-with-the-conditions-rea","errorCode":null,"errorMessage":"You did not run Node.js with the `--conditions react-server` flag. Any \"react-server\" override will only work with ESM imports.","messagePattern":"You did not run Node\\.js with the `--conditions react-server` flag\\. Any \"react-server\" override will only work with ESM imports\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/react-server-dom-esm/src/ReactFlightESMNodeLoader.js","lineNumber":82,"sourceCode":"let stashedResolve: null | ResolveFunction = null;\n\nexport async function resolve(\n  specifier: string,\n  context: ResolveContext,\n  defaultResolve: ResolveFunction,\n): Promise<{url: string}> {\n  // We stash this in case we end up needing to resolve export * statements later.\n  stashedResolve = defaultResolve;\n\n  if (!context.conditions.includes('react-server')) {\n    context = {\n      ...context,\n      conditions: [...context.conditions, 'react-server'],\n    };\n    if (!warnedAboutConditionsFlag) {\n      warnedAboutConditionsFlag = true;\n      // eslint-disable-next-line react-internal/no-production-logging\n      console.warn(\n        'You did not run Node.js with the `--conditions react-server` flag. ' +\n          'Any \"react-server\" override will only work with ESM imports.',\n      );\n    }\n  }\n  return await defaultResolve(specifier, context, defaultResolve);\n}\n\nexport async function getSource(\n  url: string,\n  context: GetSourceContext,\n  defaultGetSource: GetSourceFunction,\n): Promise<{source: Source}> {\n  // We stash this in case we end up needing to resolve export * statements later.\n  stashedGetSource = defaultGetSource;\n  return defaultGetSource(url, context, defaultGetSource);\n}\n","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/facebook/react/blob/eafeac097ba51e1eab809c07102126bd5f8e5425/packages/react-server-dom-esm/src/ReactFlightESMNodeLoader.js#L64-L100","documentation":"The react-server-dom-esm Node loader (registered via register() from react-server-dom-esm/server) hooks module resolution so packages can ship a server-only 'react-server' export. Node only passes its process-level conditions into the hook, so if node was not started with --conditions react-server, the loader appends the condition to each resolve call (ReactFlightESMNodeLoader.js:82) and warns once that the override applies only to ESM imports resolved through the hooks - CommonJS require() bypasses them entirely.","triggerScenarios":"Running `node server.js` where server.js calls register() from 'react-server-dom-esm/server' (or is launched with --import/--loader pointing at it) without --conditions react-server. The first specifier resolved after that triggers the one-time warning.","commonSituations":"Custom React Server Components node servers; tooling wrappers (tsx, nodemon, pm2, ts-node) that spawn node without forwarding flags; a CJS bootstrap requiring the ESM entry, where the injected condition never applies.","solutions":["Start node with the flag: node --conditions react-server server.js","Bake it into package.json scripts, Dockerfiles, and Procfiles so every entry point inherits it","If a wrapper swallows CLI flags, set NODE_OPTIONS='--conditions react-server' or spawn node programmatically with execArgv","Convert CJS entry points to ESM - the loader-level condition never covers require() resolution"],"exampleFix":"// before\n\"scripts\": { \"start\": \"node server.js\" }\n\n// after\n\"scripts\": { \"start\": \"node --conditions react-server server.js\" }","handlingStrategy":"validation","validationCode":"// fail fast before registering the loader\nconst args = process.execArgv.join(' ');\nif (!args.includes('--conditions') || !args.includes('react-server')) {\n  throw new Error(\n    `Start the server with: node --conditions react-server ${process.argv[1]}`,\n  );\n}\nregister(); // from 'react-server-dom-esm/server'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Hardcode --conditions react-server into every script that starts the RSC server","Set NODE_OPTIONS='--conditions react-server' for process managers that drop CLI flags","Keep the server entry as ESM so the loader-injected condition applies","Verify with node -p \"process.execArgv\" inside the target environment"],"tags":["react-server","server-components","node-loader","esm","module-resolution","conditions-flag"],"backgroundTag":"react-server-conditions-flag","analyzedSha":"eafeac097ba51e1eab809c07102126bd5f8e5425","analyzedAt":"2026-08-21T22:01:08.818Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}