question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Incompatible with React 18

See original GitHub issue

The react and react-dom libraries have been updated to version 18. Using version 18 with the react-refresh and this webpack plugin throws the following error when running webpack dev server:

ERROR in ./src/index.tsx
Module build failed (from ./node_modules/@pmmmwh/react-refresh-webpack-plugin/loader/index.js):
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './runtime.js' is not defined by "exports" in /Users/Braden/Projects/test-app/node_modules/react-refresh/package.json
    at new NodeError (node:internal/errors:371:5)
    at throwExportsNotFound (node:internal/modules/esm/resolve:453:9)
    at packageExportsResolve (node:internal/modules/esm/resolve:729:3)
    at resolveExports (node:internal/modules/cjs/loader:482:36)
    at Function.Module._findPath (node:internal/modules/cjs/loader:522:31)
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27)
    at Function.resolve (node:internal/modules/cjs/helpers:108:19)
    at Object.<anonymous> (/Users/Braden/Projects/test-app/node_modules/@pmmmwh/react-refresh-webpack-plugin/loader/index.js:20:4)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)

ERROR in ./node_modules/@pmmmwh/react-refresh-webpack-plugin/client/ReactRefreshEntry.js 4:23-58
Module not found: Error: Package path ./runtime.js is not exported from package /Users/Braden/Projects/test-app/node_modules/react-refresh (see exports field in /Users/Braden/Projects/test-app/node_modules/react-refresh/package.json)

Versions node: 16.14.0 react: 18.0.0 react-dom: 18.0.0 webpack: 5.70.0 webpack-dev-server: 4.7.4 react-refresh: 0.12.0 react-refresh-webpack-plugin: 0.5.4

Current work around is to disable react-refresh & react-refresh-webpack-plugin or downgrade to react/react-dom 17

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:15
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
jussikinnulacommented, Apr 3, 2022

Thanks for noting this. Slava Ukraini.

I can take action and publish an npm package Tomorrow which could be used until we hear back from @pmmmwh.

6reactions
jussikinnulacommented, Mar 31, 2022

I tested, and apparently the master version works well. There has been changes this year to change imports from react-refresh/runtime.js to react-refresh' (in loader.js) and to react-refresh/runtime(inclient/ReactRefreshEntry.js`).

I tested with React 18 and changing my package.json dependency from:

"@pmmmwh/react-refresh-webpack-plugin": "^0.5.4",

to:

"@pmmmwh/react-refresh-webpack-plugin": "github:pmmmwh/react-refresh-webpack-plugin",

Works without issues.

@pmmmwh, could we have a new release from master? 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

[BUG] Incompatible with react 18 · Issue #7 - GitHub
Considering the size of React 18's userbase and the amount of time it's been in beta (and, at this point, out of beta),...
Read more >
React 18 is not compatible with Fluent UI and how to work ...
React 18 is not compatible with Fluent UI and how to work around it in PCF projects. React version 18 has recently been...
Read more >
create-react-app dependency version issues with React 18
Go back to your root folder and run npx create-react-app my-app (your app name) --template file:PATH_TO_YOUR_CUSTOM_TEMPLATE.
Read more >
React v18.0 – React Blog
A key property of Concurrent React is that rendering is interruptible. When you first upgrade to React 18, before adding any concurrent features ......
Read more >
Upgrade to react 18 — Issues and resolution - Dev Genius
There is currently an incompatibility between react-router-dom@5 and React 18. Resolution: There are two resolutions I tried for this. 1. Made React.StrictMode ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found