title: TypeORM no connection options found. Suspect issue lies in dist folder and tsconfig
body: <p>package.json</p>
  <pre><code>{
    &quot;name&quot;: &quot;server&quot;,
    &quot;version&quot;: &quot;1.0.0&quot;,
    &quot;description&quot;: &quot;&quot;,
    &quot;main&quot;: &quot;dist/index.js&quot;,
    &quot;scripts&quot;: {
      &quot;build&quot;: &quot;tsc&quot;,
      &quot;start&quot;: &quot;node dist/index.js&quot;,
      &quot;dev&quot;: &quot;concurrently \&quot;tsc -w\&quot; \&quot;nodemon dist/index.js\&quot;&quot;
    },
    &quot;keywords&quot;: [],
    &quot;author&quot;: &quot;&quot;,
    &quot;license&quot;: &quot;ISC&quot;,
    &quot;devDependencies&quot;: {
      &quot;concurrently&quot;: &quot;^5.2.0&quot;,
      &quot;nodemon&quot;: &quot;^2.0.4&quot;,
      &quot;@types/node&quot;: &quot;^8.0.29&quot;,
      &quot;typescript&quot;: &quot;^3.9.6&quot;
    },
    &quot;dependencies&quot;: {
      &quot;@types/cors&quot;: &quot;^2.8.6&quot;,
      &quot;@types/express&quot;: &quot;^4.17.6&quot;,
      &quot;@types/morgan&quot;: &quot;^1.9.1&quot;,
      &quot;cors&quot;: &quot;^2.8.5&quot;,
      &quot;morgan&quot;: &quot;^1.10.0&quot;,
      &quot;mysql2&quot;: &quot;^2.1.0&quot;,
      &quot;reflect-metadata&quot;: &quot;^0.1.13&quot;,
      &quot;ts-node&quot;: &quot;^8.10.2&quot;,
      &quot;typeorm&quot;: &quot;^0.2.25&quot;
    }
  }
  </code></pre>
  <p>tsconfig</p>
  <pre><code>{
    &quot;compilerOptions&quot;: {
      &quot;experimentalDecorators&quot;: true,
      &quot;module&quot;: &quot;commonjs&quot;,
      &quot;outDir&quot;: &quot;dist&quot;,
      &quot;sourceMap&quot;: true,
      &quot;strict&quot;: true,
      &quot;target&quot;: &quot;es2017&quot;,
      &quot;resolveJsonModule&quot;: true,
      &quot;esModuleInterop&quot;: true,
      &quot;emitDecoratorMetadata&quot;: true
    },
    &quot;compileOnSave&quot;: true,
    &quot;include&quot;: [
      &quot;src&quot;
    ]
  }
  </code></pre>
  <p>File structure:</p>
  <pre><code>server
   --dist
   --src
     --typeORM
       --entity
         -- User.ts
       --migration
       --index.ts
     --index.ts (express index)
     --ormconfig.json
     --package.json
  </code></pre>
  <p>I ran the typeORM cli to get the files and removed and edited some like the package.json since i already had one from setting up express. I also renamed src to typeORM.</p>
  <p>ormconfig:</p>
  <pre><code>{
     &quot;type&quot;: &quot;mysql&quot;,
     &quot;host&quot;: &quot;localhost&quot;,
     &quot;port&quot;: 3306,
     &quot;username&quot;: &quot;root&quot;,
     &quot;password&quot;: &quot;&quot;,
     &quot;database&quot;: &quot;learningTypeORM&quot;,
     &quot;synchronize&quot;: true,
     &quot;logging&quot;: false,
     &quot;entities&quot;: [
        &quot;typeORM/entity/**/*.ts&quot;
     ],
     &quot;migrations&quot;: [
        &quot;typeORM/migration/**/*.ts&quot;
     ],
     &quot;subscribers&quot;: [
        &quot;typeORM/subscriber/**/*.ts&quot;
     ],
     &quot;cli&quot;: {
        &quot;entitiesDir&quot;: &quot;typeORM/entity&quot;,
        &quot;migrationsDir&quot;: &quot;typeORM/migration&quot;,
        &quot;subscribersDir&quot;: &quot;typeORM/subscriber&quot;
     }
  }
  </code></pre>
  <p>express index.ts</p>
  <pre><code>import express, { Request, Response } from &quot;express&quot;;
  import cors from 'cors';
  import morgan from 'morgan';
  import { PORT } from './servConsts';
  import { router as testRouter } from './routes/test';
  import { startConnection } from './typeORM/index';
  export const app: express.Application = express();
  
  app.use(cors());
  app.use(express.json());
  app.use(express.urlencoded({ extended: false }));
  app.use(morgan('dev'));
  
  startConnection();
  
  //root
  app.get('/', function (req: Request, res: Response) {
    res.send('Hello World!');
  });
  
  app.use(&quot;/test&quot;, testRouter);
  //Capture All 404 errors
  app.use(function (req: Request, res: Response) {
    res.status(404).send('Unable to find the requested resource!');
  });
  
  app.listen(PORT, function () {
    console.log(`Example app listening on port ${PORT}!`);
  });
  </code></pre>
  <p>index.js for typeORM</p>
  <pre><code>import &quot;reflect-metadata&quot;;
  import { createConnection } from &quot;typeorm&quot;;
  import { User } from &quot;./entity/User&quot;;
  
  export function startConnection() {
      createConnection(&quot;../ormconfig.json&quot;).then(async connection =&gt; {
  
          console.log(&quot;Inserting a new user into the database...&quot;);
          const user = new User();
          user.firstName = &quot;Timber&quot;;
          user.lastName = &quot;Saw&quot;;
          user.age = 25;
          await connection.manager.save(user);
          console.log(&quot;Saved a new user with id: &quot; + user.id);
  
          console.log(&quot;Loading users from the database...&quot;);
          const users = await connection.manager.find(User);
          console.log(&quot;Loaded users: &quot;, users);
  
          console.log(&quot;Here you can setup and run express/koa/any other framework.&quot;);
  
      }).catch(error =&gt; console.log(error))
  }
  </code></pre>
  <p>When i run <code>npm run dev</code> I get</p>
  <blockquote>
  <p>Error: No connection options were found in any orm configuration
  files. [1]     at ConnectionOptionsReader.
  (..../server/node_modules/typeorm/connection/ConnectionOptionsReader.js:34:35)</p>
  </blockquote>
  <p>I also noticed that the dist folder does not contain the ormconfig json file (not sure why). How do i go about fixing this?</p>