title: TypeScript help, how to set up my config?
body: <p>building a service. I have cloned a JavaScript library to import into my project and copied and pasted it.</p>
  <p>However I have compilation errors (also had them before, had to hack around)</p>
  <p>In order to get my code running I need to add this flag
  'nodemon --es-module-specifier-resolution=node app.js'</p>
  <p>Current settings:</p>
  <p><strong>package.json</strong></p>
  <pre><code>&quot;main&quot;: &quot;app.mjs&quot;, 
  ...
  &quot;type&quot;: &quot;module&quot;
  </code></pre>
  <p><strong>TSConfig.json</strong></p>
  <pre><code>&quot;target&quot;: &quot;es2020&quot;,
  &quot;module&quot;: &quot;esnext&quot;, 
  &quot;moduleResolution&quot;: &quot;node&quot;,                   
  &quot;resolveJsonModule&quot;: true,
  &quot;allowJs&quot;: true,                       
  &quot;outDir&quot;: &quot;./dist&quot;,                        
  &quot;rootDir&quot;: &quot;./&quot;,                       
  &quot;strict&quot;: true,                           
  &quot;forceConsistentCasingInFileNames&quot;: true,  
  &quot;esModuleInterop&quot;: true, 
  </code></pre>
  <p>I get error:</p>
  <blockquote>
  <p>const cbor = require('cbor') -&gt; require is not defined in ES module
  scope, use import. This file is being treated as an ES module because
  it has a '.js' file extension and 'C:\Users...\package.json' contains
  &quot;type&quot;: &quot;module&quot;. To treat it as a CommonJS script, rename it to use
  the '.cjs' file extension.</p>
  </blockquote>
  <p>Removing
  <strong>&quot;type: module&quot;</strong> =&gt;</p>
  <blockquote>
  <p>import express from 'express' -&gt; cannot use import statement outside a
  module</p>
  </blockquote>
  <p><strong>TRYING:</strong></p>
  <pre><code>   &quot;target&quot;: &quot;es6&quot;
      &quot;module&quot;: &quot;commonjs&quot;,  
  </code></pre>
  <p><strong>Package.json</strong></p>
  <pre><code>type: module
  </code></pre>
  <blockquote>
  <p>file:///C:/Users/.../dist/app.js:5 Object.defineProperty(exports,
  &quot;__esModule&quot;, { value: true });
  ReferenceError: exports is not defined in ES module scope This file is
  being treated as an ES module because it has a '.js' file extension
  and 'C:\Users\svrecic\Desktop\iot-fdo-do\package.json' contains
  &quot;type&quot;: &quot;module&quot;. To treat it as a CommonJS script, rename it to use
  the '.cjs' file extension.</p>
  </blockquote>
  <p><strong>TRYING:</strong></p>
  <pre><code>   &quot;target&quot;: &quot;es6&quot;
      &quot;module&quot;: &quot;commonjs&quot;,  
  </code></pre>
  <p><strong>Package.json</strong>
  ( Removed type: module )</p>
  <p>Get:</p>
  <blockquote>
  <p>const lowdb_1 = require(&quot;lowdb&quot;); Error [ERR_REQUIRE_ESM]: require()
  of ES Module C:\Users...\node_modules\lowdb\lib\index.js from
  C:\Users...\dist\src\lib\db.js not supported. Instead change the
  require of index.js in C:\Users...\dist\src\lib\db.js to a dynamic
  import() which is available in all CommonJS modules. Instead change
  the require of index.js ... to a dynamic import(0 which is available
  in all commonJS modules.</p>
  </blockquote>
  <p>Basically... I'm confused as heck. Fixing one error just creates a whole bunch of errors. Anyone can help me :D</p>