Yarn 3 PNP not compatible

Author: dylanpluralCreated Apr 21, 2022Updated Mar 9, 2026

If you are reporting a bug or having an issue setting up React Hot Loader, please fill in below. For feature requests, feel free to remove this template entirely.

Description

With yarn2+ (pnp enabled) is used for module resolution. hmr does not work as expected. The documented command yarn add react-dom@npm:@hot-loader/react-dom resolves in an error:

bash
yarn add react-dom@npm:@hot-loader/react-dom
➤ YN0001: │ Error: react-dom@npm:@hot-loader/react-dom isn't supported by any available resolver

And the alternative (webpack aliases) results in a runtime error:

Compiled with problems:X

ERROR in ../../.yarn/__virtual__/@szhsin-react-menu-virtual-9328d7bf3c/0/cache/@szhsin-react-menu-npm-3.0.0-c9f0bfbaf8-cfa13060d2.zip/node_modules/@szhsin/react-menu/dist/es/components/ControlledMenu.js 3:0-41

Module not found: Error: Can't resolve 'react-dom' in ...

ERROR in ../../.yarn/__virtual__/@szhsin-react-menu-virtual-9328d7bf3c/0/cache/@szhsin-react-menu-npm-3.0.0-c9f0bfbaf8-cfa13060d2.zip/node_modules/@szhsin/react-menu/dist/es/components/SubMenu.js 3:0-41

Module not found: Error: Can't resolve 'react-dom' in ...

Environment

React Hot Loader version: 17.0.2

Run these commands in the project folder and fill in their results:

  1. node -v: 16.14.2
  2. npm -v: 8.5.0
  3. yarn -v: 3.2.0

Then, specify:

  1. Operating system: Windows 10
  2. Browser and version: chrome latest

Source: gaearon/react-hot-loader