This is usually a side effect of the uneven adoption of ESM vs CommonJS and mixing of the two. It's a bit annoying, but, usually fairly easy to work around. But, a lot of it depends on how your project is configured - both the package.json and tsconfig.
Do you have the code available somewhere? I'm mostly interested in the package.json
(specifically the type
property) and tsconfig
if you have one (and this is Typescript). Also, is this a Typescript project or a regular Javascript project?
Sorry, there's several variables here that affect the proper solution.
EDIT : One more question. If this is a Typescript project, how are you executing it? Transpile then run with node? ts-node? ts-node-esm?
EDIT x2 : If you'll throw the project, or a simplified example that demonstrates the problem, up on github or somewhere else publicly accessible we should be able to fix you up pretty quickly. You can exclude the node_modules/
folder.