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

[BUG] Facing runtime error when using latest version with Next.js 12.2.4 and node v10 #1122

Closed
kashifshamaz21 opened this issue Nov 14, 2023 · 5 comments
Labels
Bug Help Wanted Stale This has not seen activity in quite some time

Comments

@kashifshamaz21
Copy link

kashifshamaz21 commented Nov 14, 2023

Bug description
I integrated the latest version (5.22.0) of the react-tooltip library in a Next.js project.
I'm running into below error related to how the resolution of the package's exports is happening when Next.js builds my App:

Error:

file:///app/node_modules/react-tooltip/dist/react-tooltip.min.mjs:7

SyntaxError: The requested module 'react' is expected to be of type CommonJS, which does not support named exports. CommonJS modules can be imported by importing the default export.

I searched for similar issues for other libraries when using them with Next.js, and found this one: 39375. But I couldn't find a solution for this for my setup.

Any help on this issue would be highly appreciated 🙏

Version of Package
v5.22.0

Next.js Version: 12.2.4
Node version: v10

@kashifshamaz21
Copy link
Author

Update:

After going through the discussion in the thread on vercel/next.js#39375 , I tried the below change, and it made the error go away:

  • I copied over dist/react-tooltip.min.mjs to my repo and renamed it to react-tooltip.min.js , i.e, rename from .mjs extension to .js. After this change, the above issue is not happening.

For the time being I'm using this temporary workaround, I'm not sure why .mjs extension would cause the above issue though.

@gabrieljablonski
Copy link
Member

gabrieljablonski commented Nov 14, 2023

We're already aware of a similar issue (probably closely related) with create-react-app not supporting .cjs files. See #1067 and our troubleshooting section.

For now, there's not much we can do, since the shift towards .cjs/.mjs/... over plain .js extensions is something that's already happening, and we'd like to follow the trend.

We'll keep this open for now and see if we figure out better ways to work around it in the future.

@gabrieljablonski
Copy link
Member

Are you still experiencing this issue? If so, are you able to upgrade to the latest NextJS version (14.0.4 as of right now) and let us know if that fixes it?

@hyoloui
Copy link

hyoloui commented Dec 20, 2023

@gabrieljablonski
Upgrading to the NextJS version (currently 14.0.4) did not resolve the issue

Copy link

This issue is stale because it has not seen activity in 30 days. Remove the stale label or comment within 14 days, or it will be closed.

@github-actions github-actions bot added the Stale This has not seen activity in quite some time label Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Help Wanted Stale This has not seen activity in quite some time
Projects
None yet
Development

No branches or pull requests

3 participants