facebook/react · error

Use react-server-dom-esm/client instead.

Error message

Use react-server-dom-esm/client instead.

What it means

The published npm artifact of react-server-dom-esm has the same root guard as the source package: npm/index.js exists only to throw and redirect imports to a subpath. This is the file actually resolved from node_modules when you import the bare package name, and it enforces the package's no-default-entrypoint design (client and server runtimes sit behind different export conditions).

Source

Thrown at packages/react-server-dom-esm/npm/index.js:12

/**
 * 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
 */

'use strict';

throw new Error('Use react-server-dom-esm/client instead.');

View on GitHub (pinned to eafeac097b)

Solutions

  1. Use 'react-server-dom-esm/client' for client decoding APIs
  2. Use 'react-server-dom-esm/server' (with the react-server condition active) for the server
  3. Correct any moduleNameMapper/alias that maps the bare specifier to the package root

Example fix

// before
const {createFromNodeStream} = require('react-server-dom-esm'); // throws

// after
const {createFromNodeStream} = require('react-server-dom-esm/client');
Defensive patterns

Strategy: validation

Validate before calling

// jest moduleNameMapper so the bare name never resolves to the guard file
// jest.config.js
module.exports = {
  moduleNameMapper: {
    '^react-server-dom-esm$': 'react-server-dom-esm/client',
    '^react-server-dom-esm/server$': 'react-server-dom-esm/npm/server.react-server.js',
  },
};

Prevention

When it happens

Trigger: `import X from 'react-server-dom-esm'` or `require('react-server-dom-esm')` resolving to node_modules/react-server-dom-esm/index.js; test configs or bundler aliases mapping the bare name; tooling that walks a package's exports and accidentally executes the root entry.

Common situations: Editor auto-import choosing the root; jest moduleNameMapper shorthand like '^react-server-dom-esm$': 'react-server-dom-esm'; code migrated from another RSC transport package.

Related errors


AI-assisted analysis of facebook/react@eafeac097b (2026-08-21). Data as JSON: /api/errors/7b3a8c568050336f. Report an issue: GitHub.