Reputation: 779
Is it possible to use ESM only and Commonjs only modules in one project?
I'm using typescript to compile and my problem is that certain packages support only ESM and certain only Commonjs, so when I'm trying to compile on changing the module output with the compiler I'm getting an error:
when using compiler option module: "ES2020"
SyntaxError: Cannot use import statement outside a module
and the other way around when using commonjs.
Upvotes: 2
Views: 531
Reputation: 6878
In your package.json
you should have
{...
"type": "module",
...}
Upvotes: 1