facebook/react · error
Use react-server-dom-esm/client instead.
Error message
Use react-server-dom-esm/client instead.
What it means
The root entrypoint of react-server-dom-esm (source packages/react-server-dom-esm/index.js) is a guard file containing nothing but this throw directing you to the client subpath. The package intentionally has no default entry because its server and client runtimes live behind different Node export conditions, so every import must name a subpath explicitly.
Source
Thrown at packages/react-server-dom-esm/index.js:10
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
throw new Error('Use react-server-dom-esm/client instead.');
View on GitHub (pinned to eafeac097b)
Solutions
- Import the RSC client from 'react-server-dom-esm/client' (createFromFetch, createFromReadableStream, createFromNodeStream)
- Import server-side APIs from 'react-server-dom-esm/server' and run under the react-server condition
- Fix bundler/jest aliases so the bare specifier never resolves to the guard file
Example fix
// before
import {createFromFetch} from 'react-server-dom-esm'; // throws
// after
import {createFromFetch} from 'react-server-dom-esm/client'; Defensive patterns
Strategy: validation
Validate before calling
// ESLint blocks bare-specifier imports before they ship
// .eslintrc: "no-restricted-imports": ["error", { "paths": [{ "name": "react-server-dom-esm", "message": "Use react-server-dom-esm/client or /server" }] }] Prevention
- Always import a subpath: react-server-dom-esm/client or react-server-dom-esm/server
- Add an eslint no-restricted-imports rule for the bare specifier
- Watch for IDE auto-imports that pick the package root
When it happens
Trigger: Importing the bare specifier: `import ... from 'react-server-dom-esm'` or `require('react-server-dom-esm')`; IDE auto-import picking the package root instead of the /client subpath; bundler or jest moduleNameMapper entries mapping the bare package name to its index.
Common situations: Auto-import completions in editors choosing the root entry; copy-pasted snippets that omitted the subpath; migration from react-server-dom-webpack where root-level imports of some helpers were possible.
Related errors
- Use react-server-dom-esm/client instead.
- Expected resolve to have been called before transformSource
- Expected the transformed source to be a string.
- The module "${modulePath}" is marked as an async ESM module
- The module "${modulePath}" is marked as an async ESM module
AI-assisted analysis of facebook/react@eafeac097b (2026-08-21).
Data as JSON: /api/errors/e8dcd8481a22242e.
Report an issue: GitHub.