title: SyntaxError: Unexpected token import TypeORM entity
body: <p>So, I am working with TypeORM and am getting an odd error when I transpile my TypeScript to JavaScript. I am receiving the following error:</p>
  <pre><code>(function (exports, require, module, __filename, __dirname) { import { Entity, PrimaryGeneratedColumn, ManyToOne, OneToMany, TreeChildren, TreeParent, JoinColumn, Column, Tree, TreeLevelColumn } from &quot;typeorm&quot;;
                                                                ^^^^^^
  
  SyntaxError: Unexpected token import
  at createScript (vm.js:80:10)
  at Object.runInThisContext (vm.js:139:10)
  at Module._compile (module.js:616:28)
  at Object.Module._extensions..js (module.js:663:10)
  at Module.load (module.js:565:32)
  at tryModuleLoad (module.js:505:12)
  at Function.Module._load (module.js:497:3)
  at Module.require (module.js:596:17)
  at require (internal/module.js:11:18)
  at Function.PlatformTools.load (C:\Users\*redacted*\Workspace\experimental\*redacted*\node_modules\typeorm\platform\PlatformTools.js:126:28)
  </code></pre>
  <p>My <code>tsconfig.json</code>:</p>
  <pre><code>{
      &quot;compilerOptions&quot;: {
          &quot;lib&quot;: [
             &quot;es5&quot;,
             &quot;es6&quot;
          ],
          &quot;target&quot;: &quot;es5&quot;,
          &quot;module&quot;: &quot;commonjs&quot;,
          &quot;moduleResolution&quot;: &quot;node&quot;,
          &quot;outDir&quot;: &quot;./build&quot;,
          &quot;emitDecoratorMetadata&quot;: true,
          &quot;experimentalDecorators&quot;: true,
          &quot;sourceMap&quot;: true
       },
      &quot;exclude&quot;: [
          &quot;client&quot;
      ]
  }
  </code></pre>
  <p>My <code>package.json</code>:</p>
  <pre><code>{
     &quot;name&quot;: &quot;*redacted*&quot;,
     &quot;version&quot;: &quot;1.0.0&quot;,
     &quot;description&quot;: &quot;&quot;,
     &quot;main&quot;: &quot;index.js&quot;,
     &quot;scripts&quot;: {
        &quot;test&quot;: &quot;echo \&quot;Error: no test specified\&quot; &amp;&amp; exit 1&quot;,
        &quot;dev&quot;: &quot;nodemon --watch 'src/**/*.ts' --ignore 'src/**/*.spec.ts' --exec ts-node src/index.ts&quot;,
        &quot;start&quot;: &quot;tsc &amp;&amp; node ./build/index.js&quot;,
        &quot;migrate&quot;: &quot;ts-node ./node_modules/typeorm/cli.js migration:generate&quot;
     },
     &quot;author&quot;: &quot;*redacted*&quot;,
     &quot;license&quot;: &quot;ISC&quot;,
     &quot;dependencies&quot;: {
        &quot;bcryptjs&quot;: &quot;^2.4.3&quot;,
        &quot;body-parser&quot;: &quot;^1.18.3&quot;,
        &quot;class-validator&quot;: &quot;^0.8.5&quot;,
        &quot;express&quot;: &quot;^4.16.3&quot;,
        &quot;jwt-simple&quot;: &quot;^0.5.1&quot;,
        &quot;morgan&quot;: &quot;^1.9.0&quot;,
        &quot;pg&quot;: &quot;^7.4.3&quot;,
        &quot;reflect-metadata&quot;: &quot;^0.1.10&quot;,
        &quot;typeorm&quot;: &quot;0.2.5&quot;
     },
     &quot;devDependencies&quot;: {
        &quot;@types/bcryptjs&quot;: &quot;^2.4.1&quot;,
        &quot;@types/body-parser&quot;: &quot;^1.17.0&quot;,
        &quot;@types/express&quot;: &quot;^4.11.1&quot;,
        &quot;@types/jwt-simple&quot;: &quot;^0.5.33&quot;,
        &quot;@types/node&quot;: &quot;^8.10.15&quot;,
        &quot;ts-node&quot;: &quot;3.3.0&quot;,
        &quot;typescript&quot;: &quot;2.5.2&quot;
     }
  }
  </code></pre>
  <p>The file throwing the error:</p>
  <pre><code>import { Entity, PrimaryGeneratedColumn, ManyToOne, OneToMany, TreeChildren, TreeParent, JoinColumn, Column, Tree, TreeLevelColumn } from &quot;typeorm&quot;;
  import { User } from &quot;./User&quot;;
  import { Debate } from &quot;./Debate&quot;;
  
  
  @Entity()
  @Tree(&quot;closure-table&quot;)
  export class Comment {
  
      @PrimaryGeneratedColumn(&quot;uuid&quot;)
      id: string;
  
      @Column()
      text: string;
  
      @ManyToOne(type =&gt; User)
      user: User;
  
      @ManyToOne(type =&gt; Debate, debate =&gt; debate.comments)
      debate: Debate;
  
      @TreeChildren()
      children: Comment[];
  
      @TreeParent()
      parent: Comment;
  }
  </code></pre>
  <p>What I have tried:</p>
  <ul>
  <li>I have tried updating my node.js to the latest (version 8.11.2)</li>
  <li>I have tried changing the &quot;lib&quot; settings in my tsconfig.json in various combinations of &quot;es5&quot;, &quot;es6&quot;, and &quot;es7&quot;</li>
  <li>I have tried changing the &quot;target&quot; for my tsconfig.json for the targets listed in the above bullet point.</li>
  <li>I have tried changing the import statements in my entity files from <code>import (lib) from (module)</code> to <code>const (lib) require (module)&quot;;</code> However, this causes more issues and doesn't work well.</li>
  </ul>
  <p>I have been googling for this issue extensively and it has left me scratching my head. Any and all help would be greatly appreciated.</p>