Closed gargmegham closed 1 year ago
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.
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.
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.
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.
https://github.com/vercel/next.js/discussions/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.
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 react-d3-speedometer@2.x
and it works great!
Code:
Error: