Error [ERR_REQUIRE_ESM]: Must use import to load ES Module
braveheart-star opened this issue · 8 comments
When I use this library in the Next.js for bubbleMap, there is building issue.
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /Users/.../[project]/node_modules/d3-geo/src/index.js
require() of ES modules is not supported.
require() of /Users/.../[project]/node_modules/d3-geo/src/index.js from /Users/.../[project]/node_modules/chartjs-chart-geo/build/index.cjs is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /Users/.../[project]/node_modules/d3-geo/package.json.
so am i
I honesty lost track which framework/builder/service uses which package.json field these days:
chartjs-chart-geo/package.json
Lines 27 to 33 in d97f017
e.g. I don't define yet type: module
re de-geo: I had to upgrade d3-geo along with d3-color to fix a major security vulnerability. However, d3 in these recent versions are only module based and that creates a lot of headache
there is no solution?
I hope to have the issue fixed asap.
atm I would recommended to downgrade to the previous version https://github.com/sgratzl/chartjs-chart-geo/releases/tag/v3.9.0
it's not working with all versions.
take a look at the latest alpha version: 4.0.0-alpha it changes this plugin to be a ESM module.
4.0.0 is start being an ESM module