title: ts-node and mocha 'TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts"' error even with "ts-node/esm" loader and CommonJS modules
body: <p>Before ask this question, I checked similar topics and tried typical solutions.</p>
  <p>I know what the frequent cause is <code>&quot;module&quot;: &quot;ESXXXX&quot;</code> in TypeScript configuration.
  In my case, I have error</p>
  <pre><code>TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension &quot;.ts&quot; for D:\IntelliJ IDEA\XXXXXX\node_modules\tsconfig-paths\src\__tests__\config-loader.test.ts
  </code></pre>
  <p>in both <code>&quot;module&quot;: &quot;ESnext&quot;</code> and <code>&quot;module&quot;: &quot;CommonJS&quot;</code> cases.</p>
  <p>One of typical solution is usage of <strong>ts-node/esm</strong>.
  First, this feature is experimental. Next, it just replace one error with another:</p>
  <pre><code>(node:24788) ExperimentalWarning: --experimental-loader is an experimental feature. This feature could change at any time
  (Use `node --trace-warnings ...` to show where the warning was created)
  
  × ERROR: CustomError: Cannot find module 'D:\IntelliJ IDEA\XXXXX\node_modules\tsconfig-paths\register' imported from D:\IntelliJ IDEA\XXXXX\node_modules\mocha\lib\nodejs\esm-utils.js
  </code></pre>
  <h2>Versions</h2>
  <ul>
  <li>mocha: 9.2.1</li>
  <li>ts-node: 10.7.0</li>
  </ul>
  <h2>Mocha config</h2>
  <pre><code>extension:
    - ts
  
  spec: &quot;**/*.test.ts&quot;
  
  require:
  
    - ts-node/register
    - tsconfig-paths/register
  
  loader: ts-node/esm # Tried with and without
  
  </code></pre>