title: return old(m, filename); Error [ERR_REQUIRE_ESM]: require() of ES Module
body: <p>i'm trying to do an integration with the unsplash api but i'm getting,</p>
  <p>when I try to run the script by ts-node like:</p>
  <pre><code>ts-node unsplash.ts
  </code></pre>
  <p>there is error for:</p>
  <pre><code>C:\Users\USER\AppData\Roaming\npm\node_modules\ts-node\dist\index.js:729
              return old(m, filename);
                     ^
  Error [ERR_REQUIRE_ESM]: require() of ES Module C:\Users\USER\Desktop\tindin\node_modules\node-fetch\src\index.js from C:\Users\USER\Desktop\tindin\src\api\services\unsplash.ts not supported.
  Instead change the require of index.js in C:\Users\USER\Desktop\tindin\src\api\services\unsplash.ts to a dynamic import() which is available in all CommonJS modules.
      at Object.require.extensions.&lt;computed&gt; [as .js] (C:\Users\USER\AppData\Roaming\npm\node_modules\ts-node\dist\index.js:729:20)
      at Object.&lt;anonymous&gt; (C:\Users\USER\Desktop\tindin\src\api\services\unsplash.ts:23:30)
      at Module.m._compile (C:\Users\USER\AppData\Roaming\npm\node_modules\ts-node\dist\index.js:735:29)
      at Object.require.extensions.&lt;computed&gt; [as .ts] (C:\Users\USER\AppData\Roaming\npm\node_modules\ts-node\dist\index.js:737:16)
      at main (C:\Users\USER\AppData\Roaming\npm\node_modules\ts-node\dist\bin.js:238:16)
      at Object.&lt;anonymous&gt; (C:\Users\USER\AppData\Roaming\npm\node_modules\ts-node\dist\bin.js:351:5) {
    code: 'ERR_REQUIRE_ESM'
  }
  </code></pre>
  <p>my code</p>
  <pre><code>import { createApi } from 'unsplash-js';
  import * as nodeFetch from 'node-fetch'
  
  const unsplash = createApi({
    accessKey: 'MY_ACCESS_KEY',
    fetch: nodeFetch.default as unknown as typeof fetch,
  });
  </code></pre>
  <p>i'm following the reference of the unsplash documentation itself
  link : <a href="https://github.com/unsplash/unsplash-js" rel="noreferrer">https://github.com/unsplash/unsplash-js</a></p>
  <p>my package.json</p>
  <pre><code>{
    &quot;name&quot;: &quot;typescript&quot;,
    &quot;version&quot;: &quot;1.0.0&quot;,
    &quot;main&quot;: &quot;server.js&quot;,
    &quot;license&quot;: &quot;MIT&quot;, 
    
    &quot;scripts&quot;: {
      &quot;dev&quot;: &quot;ts-node-dev --inspect --transpile-only --ignore-watch node_modules src/server.ts&quot;,
      &quot;lint&quot;: &quot;eslint . --ext .ts&quot;,
      &quot;lint-fix&quot;: &quot;eslint . --ext .ts --fix&quot;
    },
    &quot;devDependencies&quot;: {
      &quot;@types/node&quot;: &quot;^17.0.8&quot;,
      &quot;@typescript-eslint/eslint-plugin&quot;: &quot;^5.9.0&quot;,
      &quot;@typescript-eslint/parser&quot;: &quot;^5.9.0&quot;,
      &quot;eslint&quot;: &quot;^8.6.0&quot;,
      &quot;ts-node-dev&quot;: &quot;^1.1.8&quot;,
      &quot;tsconfig-paths&quot;: &quot;^3.12.0&quot;,
      &quot;typescript&quot;: &quot;^4.5.4&quot;
    },
    &quot;dependencies&quot;: {
      &quot;node-fetch&quot;: &quot;^3.1.1&quot;,
      &quot;unsplash-js&quot;: &quot;^7.0.15&quot;
    }
  }
    
  </code></pre>
  <p>my tsconfig.json</p>
  <pre><code>{
    &quot;compilerOptions&quot;: {
     
      &quot;target&quot;: &quot;es5&quot;,                          /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
      &quot;module&quot;: &quot;commonjs&quot;,                     /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
      &quot;allowJs&quot;: true,                          /* Allow javascript files to be compiled. */
      &quot;outDir&quot;: &quot;./build&quot;,                        /* Redirect output structure to the directory. */
      &quot;rootDir&quot;: &quot;./src&quot;,                         /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
      &quot;strict&quot;: true,                           /* Enable all strict type-checking options. */
      &quot;noImplicitAny&quot;: true,                    /* Raise error on expressions and declarations with an implied 'any' type. */
      &quot;strictPropertyInitialization&quot;: false,  /* Enable strict checking of property initialization in classes. */
  
      /* Module Resolution Options */
      &quot;moduleResolution&quot;: &quot;node&quot;,            /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
      &quot;baseUrl&quot;: &quot;.&quot;,                       /* Base directory to resolve non-absolute module names. */
     
      &quot;esModuleInterop&quot;: true,                  /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
  
      /* Experimental Options */
      &quot;experimentalDecorators&quot;: true,        /* Enables experimental support for ES7 decorators. */
      &quot;emitDecoratorMetadata&quot;: true,         /* Enables experimental support for emitting type metadata for decorators. */
  
      /* Advanced Options */
      &quot;resolveJsonModule&quot;: true,                /* Include modules imported with '.json' extension */
      &quot;forceConsistentCasingInFileNames&quot;: true, /* Disallow inconsistently-cased references to the same file. */
    },
    &quot;exclude&quot;: [
      &quot;node_modules&quot;,
      &quot;build&quot;
    ],
    &quot;include&quot;: [
      &quot;src/**/*&quot;
    ]
  }
  
  </code></pre>
  <p>I add &quot;type&quot;: &quot;module&quot; in package.json file.</p>
  <pre><code>{
    &quot;name&quot;: &quot;typescript&quot;,
    &quot;version&quot;: &quot;1.0.0&quot;,
    &quot;type&quot;: &quot;module&quot;,
  ...
  }
  </code></pre>
  <p>I get this error</p>
  <pre><code>TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension &quot;.ts&quot; for C:\Users\USER\Desktop\tindin\src\api\services\unsplash.ts
      at new NodeError (node:internal/errors:371:5)
      at Object.file: (node:internal/modules/esm/get_format:72:15)
      at defaultGetFormat (node:internal/modules/esm/get_format:85:38)
      at defaultLoad (node:internal/modules/esm/load:13:42)
      at ESMLoader.load (node:internal/modules/esm/loader:303:26)
      at ESMLoader.moduleProvider (node:internal/modules/esm/loader:230:58)
      at new ModuleJob (node:internal/modules/esm/module_job:63:26)
      at ESMLoader.getModuleJob (node:internal/modules/esm/loader:244:11)
      at async Promise.all (index 0)
      at async ESMLoader.import (node:internal/modules/esm/loader:281:24) {
    code: 'ERR_UNKNOWN_FILE_EXTENSION'
  }
  </code></pre>