Coder Social home page Coder Social logo

Comments (5)

palerdot avatar palerdot commented on August 27, 2024 1

Your build step does not understand importing es modules. You should update your app build step so that it is able to import es modules (maybe try vite, esbuild, webpack5 etc). To verify, maybe add https://www.npmjs.com/package/lodash-es as a dependency and see if you can import any of the helper functions from lodash-es. If you cannot use es modules, you will not be able to use this library.

from react-d3-speedometer.

ConnorOnTheWeb avatar ConnorOnTheWeb commented on August 27, 2024

I'm getting this error using NextJS 13. Reading that NextJS 12 and up should be able to use ES Modules by default.

It actually worked the moment I added it, but when I refresh the page or visit the page later it crashes and sends the same error re lodash.

Error: require() of ES Module /Users/user/code/project/node_modules/lodash-es/isNumber.js from /Users/user/code/project/node_modules/react-d3-speedometer/dist/core/util/index.js not supported.
Instead change the require of isNumber.js in /Users/user/code/project/node_modules/react-d3-speedometer/dist/core/util/index.js to a dynamic import() which is available in all CommonJS modules.

Code was copy pasted from the example without changes.

from react-d3-speedometer.

palerdot avatar palerdot commented on August 27, 2024

Reading that NextJS 12 and up should be able to use ES Modules by default.

Please share a nextjs documentation link to check on this behavior.

from react-d3-speedometer.

ConnorOnTheWeb avatar ConnorOnTheWeb commented on August 27, 2024

Reading that NextJS 12 and up should be able to use ES Modules by default.

Please share a nextjs documentation link to check on this behavior.

vercel/next.js#29348

Not finding much documentation on the main website, only in Issues. It sounds very simple, with two solutions... I've tried adding "type": "module" and it broke Next Auth. I've tried adding the .mjs extension to the page, but then the page shows a 404. So, I'm not really sure what's to be done about ES Modules here.

Currently getting it to work (very slow) on routed-to instances and ~50% of page refreshes by bringing it in as a dynamic import. It's still throwing a fit about react-d3-speedometer importing lodash-es/isNumber.js.

from react-d3-speedometer.

ConnorOnTheWeb avatar ConnorOnTheWeb commented on August 27, 2024

Found the issue. When I installed using yarn add react-d3-speedometer it was installing version 1.x which the documentation says works for React 17. I am using React 18, recognized the version number and installed using yarn add [email protected] and it works great!

from react-d3-speedometer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.