SyntaxError: Unexpected token import typeORM entity : <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 "typeorm";
                                                              ^^^^^^

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 tsconfig.json: </p>

<pre><code>{
    "compilerOptions": {
        "lib": [
           "es5",
           "es6"
        ],
        "target": "es5",
        "module": "commonjs",
        "moduleResolution": "node",
        "outDir": "./build",
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "sourceMap": true
     },
    "exclude": [
        "client"
    ]
}
</code></pre>

<p>My package.json:</p>

<pre><code>{
   "name": "*redacted*",
   "version": "1.0.0",
   "description": "",
   "main": "index.js",
   "scripts": {
      "test": "echo \"Error: no test specified\" &amp;&amp; exit 1",
      "dev": "nodemon --watch 'src/**/*.ts' --ignore 'src/**/*.spec.ts' --exec ts-node src/index.ts",
      "start": "tsc &amp;&amp; node ./build/index.js",
      "migrate": "ts-node ./node_modules/typeorm/cli.js migration:generate"
   },
   "author": "*redacted*",
   "license": "ISC",
   "dependencies": {
      "bcryptjs": "^2.4.3",
      "body-parser": "^1.18.3",
      "class-validator": "^0.8.5",
      "express": "^4.16.3",
      "jwt-simple": "^0.5.1",
      "morgan": "^1.9.0",
      "pg": "^7.4.3",
      "reflect-metadata": "^0.1.10",
      "typeorm": "0.2.5"
   },
   "devDependencies": {
      "@types/bcryptjs": "^2.4.1",
      "@types/body-parser": "^1.17.0",
      "@types/express": "^4.11.1",
      "@types/jwt-simple": "^0.5.33",
      "@types/node": "^8.10.15",
      "ts-node": "3.3.0",
      "typescript": "2.5.2"
   }
}
</code></pre>

<p>The file throwing the error:</p>

<pre><code>import { Entity, PrimaryGeneratedColumn, ManyToOne, OneToMany, TreeChildren, TreeParent, JoinColumn, Column, Tree, TreeLevelColumn } from "typeorm";
import { User } from "./User";
import { Debate } from "./Debate";


@Entity()
@Tree("closure-table")
export class Comment {

    @PrimaryGeneratedColumn("uuid")
    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 "lib" settings in my tsconfig.json in various combinations of "es5", "es6", and "es7"</li>
<li>I have tried changing the "target" 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 "import (lib) from (module)" to "const (lib) require (module)"; 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>
