Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

3
  • 2
    Quick note is that .js extension is because the TS team is outspoken for not wanting to rewrite paths (see Ryan's comment here). That does not take away from the fact that the answer is, indeed, correct - if ESM is used in tests, the target should be set accordingly. Commented Apr 30, 2022 at 21:18
  • I have mts files that get converted to mjs. I import from these mjs and still get the error.
    – Timo
    Commented Jan 21 at 18:08
  • I do not use type:module in package.json - default is commonjs and now the imports work as described by Anonymous Creator. I import from mjs files and not js.
    – Timo
    Commented Jan 22 at 20:29