react-toastify: [CRA v4] Can't import the named export 'cloneElement' from non EcmaScript module. PLEASE UPGRADE YOUR CRA VERSION 😿
Do you want to request a feature or report a bug?
A Bug
What is the current behavior?
v9.0.4 seems to add a breaking change .
My setup works with V9.0.3, but when updating to V9.0.4 react scripts refuse to build
./node_modules/react-toastify/dist/react-toastify.esm.mjs
Can't import the named export 'cloneElement' from non EcmaScript module (only default export is available)
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
React 17.0.1 react-scripts 4.0.1 ( with typescript )
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 45
- Comments: 52 (10 by maintainers)
Commits related to this issue
- Install react-toastify@9.0.3 I pinned to version 9.0.3 due to this issue: https://github.com/fkhadra/react-toastify/issues/775 — committed to josephfrazier/reported-web by josephfrazier a year ago
- Use toast notification instead of modal for warning/success messages (#397) See https://reportedcab.slack.com/archives/C9VNM3DL4/p1672888880155269: > What do you think of replacing the react modal... — committed to josephfrazier/reported-web by josephfrazier a year ago
Exact same issue for me.
@Joshua-Enrico it works with
9.0.3too . only the9.0.4introduce this changeNot the best fix at the moment, but I opted to replace the version I was using with a minor one. “react-toastify”: “^9.0.1” > “react-toastify”: “9.0.0”,
I’ve also found this solution, for those who cannot migrate to v5 https://github.com/reactioncommerce/reaction-component-library/issues/399#issuecomment-467860022
I got this error using 9.0.5. I went down to 9.0.3 and now it works.
Same here
9.0.3seems to work fine though.i have the same issue and i have used create-react-app my react-toastify version is ^9.0.8. please help me Here is the full message: ./node_modules/react-toastify/dist/react-toastify.esm.mjs Can’t import the named export ‘cloneElement’ from non EcmaScript module (only default export is available)
cool, I fixed the version of react-toastify to 9.0.3 when working on project SP Extensions
Im getting this issue using the latest version of storybook and react, and its actually crashing my storybook.
This solution works for me! Thanks!
@thib3113 regarding semver, this is debatable. There are no breaking changes introduced in the library itself. The main issue is that CRA v4 does not support es module.
But as I said, this is debatable, so as a consumer of the package, I understand your point of view as well.
The current JS ecosystem is moving to es modules, there is a lot of friction but, passed that point, I believe that the ecosystem will get better. As a maintainer, we are the driving force of this change.
Anyway, I digress. I’ll check with other maintainers about how they handled this change. Sorry for the trouble 🙏
still an issue with ^9.1.1
I will close the issue here .
If you got this error, you can : -> fix the version of react-toastify to 9.0.3 -> upgrade to CRA 5 / webpack 5
But, CRA 5 / webpack 5 stop including nodejs polyfills by defaults
So, if you got errors with storybook, or any other error related, you need to add them manually ( you can find more informations on the CRA repository, or on the web ) .
About the why it works with 9.0.3 and not with 9.0.4, it’s writted in the release note of the 9.0.4
Yes, I totally want to upgrade to CRA5 but this leads to other issues (missing polyfills, as you’re obviously aware)? So, for now, I’ll stick to CRA4 and react-toastify 9.0.3. And as soon as my workload allows it, I’ll upgrade everything.
I just wanted to know if something was in progress regarding this issue, but I truly understand that’s not a trivial dev.
Thanks!
@Snouzy either you upgrade CRA or you switch to vite. I’d like to remind that CRA v4 is more than 2 years old.
For me this fixed storybook https://github.com/storybookjs/storybook/issues/16690#issuecomment-971579785
My issue is solved by update the react-script and node version.
I’ll try tomorrow with the rewired solution and keep you posted
It would be nice if it is not a requirement and expectation to upgrade to react CRA 5. This time I can safely say most of the sites have not been upgraded due to the breaking change. I really like this plugin.
Hey @Robloche, I understand your concern but supporting something that’s 2 years old + modern bundlers is a lot of work. Can’t you upgrade CRA? As a maintainer, we are supposed to drive the changes to the modern module system but we also need your help with that. If you want to stick with CRA v4 there is this workaround https://github.com/reactioncommerce/reaction-component-library/issues/399#issuecomment-467860022