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

D3 related build issue - use import() instead of require() #133

Open
AnnieTaylorCHEN opened this issue Jun 19, 2023 · 3 comments
Open

D3 related build issue - use import() instead of require() #133

AnnieTaylorCHEN opened this issue Jun 19, 2023 · 3 comments

Comments

@AnnieTaylorCHEN
Copy link

Hi, I have other libraries that depend on lower versions of D3 to work, and currently I am having this error in the build:

Error: require() of ES Module /builds/.../node_modules/d3/src/index.js from /builds/.../node_modules/react-gauge-chart/dist/GaugeChart/index.js not supported.
Instead change the require of /builds/.../node_modules/d3/src/index.js in /builds/.../node_modules/react-gauge-chart/dist/GaugeChart/index.js to a dynamic import() which is available in all CommonJS modules.

Which version should I downgrade to avoid this issue? @Martin36 Thanks!

@AnnieTaylorCHEN
Copy link
Author

It seems 0.4.0 will not do since it doesn't support React 18.

@ck256-2000
Copy link

This link 100% worked for my install - same issue - wouldn't let me leave feedback at Stack Overflow - Good luck! https://stackoverflow.com/questions/75555873/error-require-of-es-module-in-react-gauge-chart-nextjs?newreg=5251096e281a46a294415af2210f9c55

import dynamic from "next/dynamic";
const GaugeChart = dynamic(() => import('react-gauge-chart'), { ssr: false });

@KoehlerAlexander
Copy link

For anyone not using next, what worked for me was utilizing React.lazy for importing the GaugeChart:

const GaugeChart = lazy(() => import("react-gauge-chart"))

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

3 participants