Skip to content
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

[CRA v4] Can't import the named export 'cloneElement' from non EcmaScript module. PLEASE UPGRADE YOUR CRA VERSION 😿 #775

Closed
thib3113 opened this issue Jun 7, 2022 · 53 comments
Assignees

Comments

@thib3113
Copy link

thib3113 commented Jun 7, 2022

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 )

@Robloche
Copy link

Robloche commented Jun 8, 2022

Exact same issue for me.

@fkhadra
Copy link
Owner

fkhadra commented Jun 8, 2022

I'm on it

@fkhadra
Copy link
Owner

fkhadra commented Jun 8, 2022

@Robloche you are using latest CRA?

@fkhadra
Copy link
Owner

fkhadra commented Jun 8, 2022

@cakonze, @niwa-takeru, @thib3113, just tested with the latest CRA and it works as expected. I suggest you upgrade to the latest CRA. 4.0.1 is almost 2 years old

@fkhadra fkhadra changed the title Can't import the named export 'cloneElement' from non EcmaScript module [CRA v4] Can't import the named export 'cloneElement' from non EcmaScript module Jun 8, 2022
@fkhadra fkhadra self-assigned this Jun 8, 2022
@thib3113
Copy link
Author

thib3113 commented Jun 8, 2022

@fkhadra not so easy ...

CRA 5 use webpack 5, which remove node js polyfill ; And lot of people can't migrate to it : facebook/create-react-app#11756 .

About my personal case, I'm actually migrating to V5, but it will took a long time (because I need to rewrite/re publish some libraries that use polyfill)

@fkhadra
Copy link
Owner

fkhadra commented Jun 8, 2022

@thib3113 I want to 😭. The module system in our ecosystem is so messy. If I revert the PR then I would break vitejs and nextjs. I don't see any good solution

I understand your pain, believe me. What I can suggest is to stick to v9.0.3 until you fully migrated to CRA v5.

Edit: I'll update the release note to mention the issue with CRA v4

@fkhadra
Copy link
Owner

fkhadra commented Jun 8, 2022

I've also found this solution, for those who cannot migrate to v5 reactioncommerce/reaction-component-library#399 (comment)

@thib3113
Copy link
Author

thib3113 commented Jun 8, 2022

@fkhadra thank you, but it's not really a solution with react-scripts . It's a solution to doesn't use it :) . ( but, my case is "pretty" easy, I'm just using an old library, that is preparing a big major update ... and so doesn't update the last one ... I will start by trying to fix it, and do a PR, before switching to another things )


About the change, the main problem for me is maybe the version change ... patch need to doesn't contains breaking changes and only bugfixes . ( but in fact ^9.0.1 will match 9.1.0 too ... ) .

@Robloche
Copy link

Robloche commented Jun 8, 2022

@Robloche you are using latest CRA?

Unfortunately, no. I would like to but I've got troubles with a couple of npm packages that weren't designed to be used in a browser but were supported until CRA 4.

@fkhadra
Copy link
Owner

fkhadra commented Jun 8, 2022

@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 🙏

@cakonze
Copy link

cakonze commented Jun 8, 2022

I've also found this solution, for those who cannot migrate to v5 reactioncommerce/reaction-component-library#399 (comment)

This solution works for me! Thanks!

@forgowhisky
Copy link

also getting this

@Joshua-Enrico
Copy link

Not 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",

@thib3113
Copy link
Author

thib3113 commented Jun 9, 2022

@Joshua-Enrico it works with 9.0.3 too . only the 9.0.4 introduce this change

@dimitur2204
Copy link

Same here 9.0.3 seems to work fine though.

@sumitk-singh
Copy link

having the same isuue

@fmenes01
Copy link

same problem

@mahmoud-ahmed-elqenawey

having the same isuue

@djaffer
Copy link

djaffer commented Jun 16, 2022

same issue. Thanks @fkhadra for solution.

@bluepeter
Copy link

bluepeter commented Jun 21, 2022

Still the same issue in 9.0.5

@drethedevjs
Copy link

Not 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 got this error using 9.0.5. I went down to 9.0.3 and now it works.

@Robloche
Copy link

Hello,
Can we get an update on this issue, please?
Not a real blocker since we can stick to v9.0.3 but we're slowly drifting away from the latest version...

@fkhadra
Copy link
Owner

fkhadra commented Jul 19, 2022

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 reactioncommerce/reaction-component-library#399 (comment)

@Robloche
Copy link

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!

@djaffer
Copy link

djaffer commented Jul 20, 2022

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.

@ashikibrahim
Copy link

ashikibrahim commented Jul 29, 2022

i had this error => "Can't import the named export 'cloneElement' from non EcmaScript module"
i had tried many other ways but coudnt find a solution
at last i updated the react-script version 2.0.3 to 5.0.1 and i corrected the issue.

@PranoySarker
Copy link

My issue is solved by update the react-script and node version.

@cristoferrao
Copy link

thanks

@garvae
Copy link

garvae commented Sep 22, 2022

same issue

"react-toastify": "^9.0.8"
"react-scripts": "^4.0.3"
"react": "^18.2.0"
"react-dom": "^18.2.0"

@congduong97
Copy link

Not 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",

It work for me, Thanks

@John-Yue
Copy link

Not 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 got this error using 9.0.5. I went down to 9.0.3 and now it works.

Me too!!!

@ruymaster
Copy link

Also I got this issue.

./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)

@iamrosada
Copy link

The some issue
./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)

@fkhadra fkhadra changed the title [CRA v4] Can't import the named export 'cloneElement' from non EcmaScript module [CRA v4] Can't import the named export 'cloneElement' from non EcmaScript module. PLEASE UPGRADE YOUR CRA VERSION 😿 Oct 8, 2022
@cpvalente
Copy link

Hi, I am having this issue in a non CRA boilerplate but in a project with just storybook and webpack, probably same scenario as @The-Code-Monkey

"@storybook/react": "^6.5.12",
"webpack": "^4.41.5",
"webpack-cli": "^3.3.10"

what exactly in CRA5 makes the system work? I am looking to manually upgrade the necessary dependency but slightly unsure on where the break is here

@dimitur2204
Copy link

dimitur2204 commented Oct 14, 2022

Hi, I am having this issue in a non CRA boilerplate but in a project with just storybook and webpack, probably same scenario as @The-Code-Monkey

"@storybook/react": "^6.5.12",
"webpack": "^4.41.5",
"webpack-cli": "^3.3.10"

what exactly in CRA5 makes the system work? I am looking to manually upgrade the necessary dependency but slightly unsure on where the break is here

@cpvalente Try different versions of webpack, I honestly doubt the issue is anywhere else

Edit: That would also mean that the problems is not in CRA, but rather in webpack. I don't know if it matters to anyone though since the maintainers said they wouldn't be supporting older versions of bundlers!

@aspirisen
Copy link

For me this fixed storybook storybookjs/storybook#16690 (comment)

@thib3113
Copy link
Author

thib3113 commented Oct 28, 2022

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

@linhvuquach
Copy link

cool, I fixed the version of react-toastify to 9.0.3 when working on project SP Extensions

@Snouzy
Copy link

Snouzy commented Nov 13, 2022

Same here. So it's time to switch to vite ? ahah

@fkhadra
Copy link
Owner

fkhadra commented Nov 13, 2022

@Snouzy either you upgrade CRA or you switch to vite. I'd like to remind that CRA v4 is more than 2 years old.

@Snouzy
Copy link

Snouzy commented Nov 13, 2022

Yup ahah, i will !
thanks buddy :)

josephfrazier added a commit to josephfrazier/reported-web that referenced this issue Jan 21, 2023
I pinned to version 9.0.3 due to this issue: fkhadra/react-toastify#775
josephfrazier added a commit to josephfrazier/reported-web that referenced this issue Jan 24, 2023
@jessewriter
Copy link

still an issue with ^9.1.1

@thib3113
Copy link
Author

thib3113 commented Mar 10, 2023

@jessewriter this issue will not be fixed : #775 (comment)

@ASADRAZAASCEND
Copy link

Still facing the same issue in node v22.1.0. there error is "133.0 ./node_modules/react-toastify/dist/react-toastify.esm.mjs
133.0 Can't import the named export 'cloneElement' from non EcmaScript module (only default export is available)".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests