{"record":{"id":"854d02b79972de99","repo":"facebook/react","slug":"the-react-server-cannot-be-used-outside-a-react-se-854d02","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-webpack/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-webpack/server.js#L1-L14","documentation":"react-server-dom-webpack/server.js is the default (non-react-server) branch of the './server' export: when Node's module resolution does not have the 'react-server' condition active, this stub throws on import. It protects the Flight server implementation from being loaded into a client or plain Node context where its bundler-manifest expectations make no sense.","triggerScenarios":"import ... from 'react-server-dom-webpack/server' executed without --conditions react-server; a bundler compiling this module into a browser bundle (no react-server conditionName).","commonSituations":"Accidentally importing the server entry from shared/client code | Dev servers/proxies that bundle server files for HMR without the condition | Missing condition in jest/ts-node/bun configurations","solutions":["Keep server imports out of shared modules; import 'react-server-dom-webpack/client' in browser code","Run the server with node --conditions react-server and configure bundler conditionNames/test conditions with 'react-server'","Grep the client bundle output for 'react-server-dom-webpack/server' to find the offending import"],"exampleFix":"// before: shared module imports server entry unconditionally\nimport {renderToPipeableStream} from 'react-server-dom-webpack/server';\n\n// after: only the server bundle (built with conditions: ['react-server']) imports it,\n// client bundle imports the client entry\nimport {createFromReadableStream} from 'react-server-dom-webpack/client';","handlingStrategy":"validation","validationCode":"// keep client and server imports in separate files; assert at build time\n// webpack client config resolve aliases to catch accidents:\nresolve: {alias: {'react-server-dom-webpack/server': false}}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never import /server from shared modules; branch on subpath files instead","Add 'react-server' to the server graph's conditionNames","Grep client bundle output for '/server' imports as a CI check"],"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"}