title: Syntax Error: Unexpected token { on compiled typescript
body: <p>When I try to run my compiled typescript code I get a syntax error:</p>
  
  <pre><code>\entity\Config.ts:1
  (function (exports, require, module, __filename, __dirname) { import { Entity, PrimaryGeneratedColumn, Column, BaseEntity } from "typeorm";
                                                                       ^
  
  SyntaxError: Unexpected token { 
  </code></pre>
  
  <p>but when I run the typescript code with <code>ts-node</code> and <code>nodemon</code> code runs just fine. </p>
  
  <p>So I've worked on some logging to figure out where the problem is occurring and it seems to happen when I hit <code>createConnection()</code> method on TypeORM. I'm new to Typescript and the TypeORM library.</p>
  
  <p>entity/config.ts</p>
  
  <pre><code>import { Entity, PrimaryGeneratedColumn, Column, BaseEntity } from "typeorm";
  
  @Entity()
  export class Config extends BaseEntity {
    @PrimaryGeneratedColumn()
    id: number;
  
    @Column()
    app: String;
  
    @Column()
    endpoint: String;
  
    @Column()
    token: String;
  }
  </code></pre>
  
  <p>server.ts</p>
  
  <pre><code>import { createConnection } from "typeorm";
  
  // Database connected
  createConnection()
    .then(() =&gt; {
      console.log("Test");
    })
    .catch(err =&gt; {
      console.log(err);
    });
  </code></pre>
  
  <p>index.ts</p>
  
  <pre><code>require("reflect-metadata");
  require("dotenv/config");
  require("./server");
  </code></pre>
  
  <p>package.json dependancies</p>
  
  <pre><code>    "scripts": {
      "dev:server": "ts-node src",
      "dev": "nodemon -e ts -w src -x npm run dev:server",
      "build:server": "tsc",
      "start:server": "node build/index.js",
      "start": "npm run build:server &amp;&amp; npm run start:server"
    },
    "keywords": [],
    "author": "",
    "license": "MIT",
    "devDependencies": {
      "@types/axios": "^0.14.0",
      "@types/graphql": "^14.0.3",
      "@types/node": "^10.12.18",
      "@types/winston": "^2.4.4",
      "nodemon": "^1.18.9",
      "ts-node": "^7.0.1",
      "typescript": "^3.2.2"
    },
    "dependencies": {
      "apollo-server-express": "^2.3.1",
      "axios": "^0.18.0",
      "dotenv": "^6.2.0",
      "express": "^4.16.4",
      "graphql": "^14.0.2",
      "pg": "^7.7.1",
      "reflect-metadata": "^0.1.12",
      "sequelize": "^4.42.0",
      "typeorm": "^0.2.9",
      "winston": "^3.1.0"
    }
  }
  </code></pre>