TypeScript compiler would give an error: Module 'yjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
Thank you for replying. May I please ask instead of "module": "CommonJS", what kind of module would you recommend we generate for Node.js applications? I’ve tried changing it to both “ESNext” and “NodeNext”. Unfortunately neither worked.
@dizy I recommend using a different template for tsconfig. There is something wrong with yours. This one works perfectly. I’ve also seen others that consume yjs without problems (e.g. jupyterlab/jupyterlab).
If you transpile your code before execution, then you should definitely use ESM and transpile to CJS if needed. Otherwise: if you start fresh give ESM a try. It’s sometimes harder to migrate existing projects.