boly38/node-mongotools

ERR_REQUIRE_ESM - node reports an error after import,

Closed this issue · 3 comments

What do I need to do

Hi @catkinmu

Really sorry for the delay, I completely miss that repository issues since a while :/

I think you're trying to use this module from CommonJS project but this project is an ES Module
(Im not 100% sure but I think in state they are not compatibles :( or maybe with some glue I'm not aware of)
https://www.syncfusion.com/blogs/post/js-commonjs-vs-es-modules

I recommend - if your project is not too big - to move your project as an ES module so using "type : module" in your package.json and relying on import instead of require.. a more modern JS.

I'll add a mention in readme about commonjs to fix this kind of question in the future