{"record":{"id":"7b3a8c568050336f","repo":"facebook/react","slug":"use-react-server-dom-esm-client-instead-7b3a8c","errorCode":null,"errorMessage":"Use react-server-dom-esm/client instead.","messagePattern":"Use react-server-dom-esm/client instead\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/react-server-dom-esm/npm/index.js","lineNumber":12,"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\n'use strict';\n\nthrow new Error('Use react-server-dom-esm/client instead.');\n","sourceCodeStart":1,"sourceCodeEnd":13,"githubUrl":"https://github.com/facebook/react/blob/eafeac097ba51e1eab809c07102126bd5f8e5425/packages/react-server-dom-esm/npm/index.js#L1-L13","documentation":"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).","triggerScenarios":"`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.","commonSituations":"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.","solutions":["Use 'react-server-dom-esm/client' for client decoding APIs","Use 'react-server-dom-esm/server' (with the react-server condition active) for the server","Correct any moduleNameMapper/alias that maps the bare specifier to the package root"],"exampleFix":"// before\nconst {createFromNodeStream} = require('react-server-dom-esm'); // throws\n\n// after\nconst {createFromNodeStream} = require('react-server-dom-esm/client');","handlingStrategy":"validation","validationCode":"// jest moduleNameMapper so the bare name never resolves to the guard file\n// jest.config.js\nmodule.exports = {\n  moduleNameMapper: {\n    '^react-server-dom-esm$': 'react-server-dom-esm/client',\n    '^react-server-dom-esm/server$': 'react-server-dom-esm/npm/server.react-server.js',\n  },\n};","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Import subpaths only (client/server), never the package root","Fix bundler aliases and jest moduleNameMapper that map the bare specifier","Reject auto-generated imports of the root entry in code review or via lint rule"],"tags":["react-server-components","entrypoint","api-misuse","npm"],"backgroundTag":"package-entrypoint-guard","analyzedSha":"eafeac097ba51e1eab809c07102126bd5f8e5425","analyzedAt":"2026-08-21T22:01:08.818Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}