title: Sequalise: TypeError: Class constructor Modal cannot be invoked without 'new' (typescript)
body: <p>I am using typescript in node and it works great in development mode by running my index.ts with ts-node using the following command.</p>
  <pre><code>ts-node src/index.ts
  </code></pre>
  <p>but when I transpile my typescript code into es6 and run index.js file using the simple node command</p>
  <pre><code>node dist/index.js
  </code></pre>
  <p>it throws the error that</p>
  <pre><code>/home/ubuntu/Projects/projects/Servers/test-server/node_modules/sequelize/lib/sequelize.js:486
    this.importCache[importPath] = defineCall(this, DataTypes);
                                   ^
   TypeError: Class constructor Modal cannot be invoked without 'new'
  at Sequelize.import (/home/ubuntu/Projects/projects/Servers/test-server/node_modules/sequelize/lib/sequelize.js:486:38)
  </code></pre>
  <p>below is my tsconfig.json file</p>
  <pre><code>{
   &quot;compilerOptions&quot;: {   
    &quot;target&quot;: &quot;ES2015&quot;,
    &quot;module&quot;: &quot;commonjs&quot;,
    &quot;outDir&quot;: &quot;./dist&quot;,  
    &quot;rootDir&quot;: &quot;./src&quot;,
    &quot;strict&quot;: true, 
    &quot;moduleResolution&quot;: &quot;node&quot;, 
    &quot;esModuleInterop&quot;: true,
    &quot;forceConsistentCasingInFileNames&quot;: true 
   }
  }
  </code></pre>
  <p>I tried everything solutions available related to this error but nothing works for me and still getting this error.</p>
  <p>this is my sequelize index file.</p>
  <pre><code>import { Sequelize } from &quot;sequelize&quot;;
  import config from &quot;../config&quot;;
  import fs from &quot;fs&quot;;
  import path from &quot;path&quot;
  
  export default class Modal {
  public db: any = {};
  private config = new config().config
  constructor() {
      this.registerSchemaInDB();
  }
  private sql: any = new Sequelize(
      'mysql://' + this.config.database.username + ':' + this.config.database.password + '@localhost:3306/' + this.config.database.name, {
      dialect: &quot;mysql&quot;,
      host: this.config.database.host
  });
  private registerSchemaInDB = () =&gt; {
      fs.readdirSync(__dirname)
          .filter((file) =&gt; {
              return (file.indexOf(&quot;.&quot;) !== 0) &amp;&amp; (file !== &quot;index.ts&quot;) ;
          })
          .forEach((file) =&gt; {
              console.log(file);
              let model = this.sql.import(path.join(__dirname, file));
              this.db[model.name] = model;
          });
  
      Object.keys(this.db).forEach((modelName) =&gt; {
          if (&quot;associate&quot; in this.db[modelName]) {
              this.db[modelName].associate(this.db);
          }
      });
      this.db.sequelize = this.sql
  }
  </code></pre>
  <p>}</p>
  <blockquote>
  <p>Node version v12.14.0</p>
  <p>Sequelize version 5.21.3</p>
  </blockquote>
  <p>thx in advance</p>