Nooblantis District
Nooblantis District

Reputation: 141

Error: require() of ES Module in React-gauge-chart, NextJs

it shows this error

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

Upvotes: 1

Views: 1373

Answers (1)

Nooblantis District
Nooblantis District

Reputation: 141

Import using next dynamic

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

Upvotes: 2

Related Questions