D3-array produces ERR_REQUIRE_ESM with node >= 15
QuinAiton opened this issue · 3 comments
Node >=15 seems to make breaking changes to both the D3-array library and the D3-Time-format library. Even after applying all the given solutions in the Error message I cannot seem to kick this error.... Could it be an issue with a package D3 relies on? Any solutions would be greatly appreciated as our product relies heavily on the D3 libraries and this has created a large roadblock in our next release.
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /Users/quin.aiton/hakai/hakai-data-portal-v2/node_modules/d3-array/src/index.js require() of ES modules is not supported. require() of /Users/quin.aiton/hakai/hakai-data-portal-v2/node_modules/d3-array/src/index.js from /Users/quin.aiton/hakai/hakai-data-portal-v2/src/features/ctd/download/reducer.js 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/quin.aiton/hakai/hakai-data-portal-v2/node_modules/d3-array/package.json.
Please read the release notes.
Try scrolling down and looking for the latest major version number bump, which indicates a breaking change.