-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: [5.0] Can't resolve 'react/jsx-runtime' #11769
Comments
Hi, I have the same issue when running
Digging a bit in webpack issues led me to this solution. Hardcoding this rule in CRA v5 webpack.config.js makes the error disappear but I guess there's no way to edit the config without ejecting? |
I have the same error in some packages There is no solution without eject?? |
There is, you can use It's 100x easier than ejecting. |
It's not an issue in Webpack nor Create react app - Yes we could work around it, but would rather keep our code free of that and push back on package maintainers as this is not an issue isolated to CRA E.g. regarding
Why not workaround vs fixing the packages... Should be fixed in React v18 - but can it be backported to react 17/16? - it would solve the issue community wise - so hesitant to add workarounds in CRA @gaearon any insights? |
@raix I agree with you but a simple entry in Webpack config fixes it (which is equivalent to what React 18 does): diff --git a/node_modules/react-scripts/config/webpack.config.js b/node_modules/react-scripts/config/webpack.config.js
index 2b1b3bb..745ef7e 100644
--- a/node_modules/react-scripts/config/webpack.config.js
+++ b/node_modules/react-scripts/config/webpack.config.js
@@ -318,6 +318,10 @@ module.exports = function (webpackEnv) {
.map(ext => `.${ext}`)
.filter(ext => useTypeScript || !ext.includes('ts')),
alias: {
+ // https://github.com/facebook/react/issues/20235
+ // https://github.com/facebook/create-react-app/issues/11769
+ "react/jsx-dev-runtime": "react/jsx-dev-runtime.js",
+ "react/jsx-runtime": "react/jsx-runtime.js",
// Support React Native Web
// https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/
'react-native': 'react-native-web', |
Added the workaround in #11797 - should get out in next patch release v5.0.1 |
Is there a way we can get this working while we wait for the patch release? |
@badsyntax weird. Didn't resolve my issues. |
@artivilla it's fairly straightforward if you follow the README but here's some detailed instructions facebook/react#20235 (comment) |
Yep, no I managed to do the patch but I was still running into the same issue so for now I've just downgraded to jest@26. Will take when the patch is released. Either way patch-package is v neat library! |
patch-package won't work if you're using yarn 3/pnp. |
Describe the bug
Importing the package
react-data-grid
results int he following error uponyarn start
:No error is observed in CRA 4.
Did you try recovering your dependencies?
Yes.
Which terms did you search for in User Guide?
Searched for:
Can't resolve 'react/jsx-runtime'
Environment
Steps to reproduce
react-data-grid
Expected behavior
No error, like in 4.0
The text was updated successfully, but these errors were encountered: