palerdot / react-d3-speedometer

React Speedometer component using d3.js ⚛️
https://palerdot.in/react-d3-speedometer/
MIT License
230 stars 57 forks source link

loadash error on use in server side next.js #141

Closed rrfaria closed 2 years ago

rrfaria commented 2 years ago

I only instaled and used example on next :

<ReactSpeedometer
    value={777}
    currentValueText="Happiness Level"
    customSegmentLabels={[
    {
        text: "Very Bad",
        position: CustomSegmentLabelPosition.Inside,
        color: "#555",
    },
    {
        text: "Bad",
        position: CustomSegmentLabelPosition.Inside,
        color: "#555",
    },
    {
        text: "Ok",
        position: CustomSegmentLabelPosition.Inside,
        color: "#555",
        fontSize: "19px",
    },
    {
        text: "Good",
        position: CustomSegmentLabelPosition.Inside,
        color: "#555",
    },
    {
        text: "Very Good",
        position: CustomSegmentLabelPosition.Inside,
        color: "#555",
    },
    ]}
/>

And this error appear:

Error: Must use import to load ES Module: node_modules/lodash-es/isNumber.js
require() of ES modules is not supported.
palerdot commented 2 years ago

Please refer this issue for how to use ES modules with next.js - https://github.com/palerdot/react-d3-speedometer/issues/89

This issue and solution has already mentioned as FAQ in README.