title: unit-tests SyntaxError: Unexpected token {
body: <p>I get this error:</p>
  
  <pre><code>D:\nginx\ibdrweb\webapps\ibdr-document-2\doc-app\sources\forms\dynamic-form\lus\lus.js:1
  import { Tools } from "@ShareUtils/tools";
         ^
  
  SyntaxError: Unexpected token {
      at Module._compile (internal/modules/cjs/loader.js:721:23)
      at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
  </code></pre>
  
  <p>when i try to execute the following comand:</p>
  
  <pre><code>ts-mocha -p doc-app/tests/tsconfig.json doc-app/tests/lus-tests.ts
  </code></pre>
  
  <p>This issue was discussed here <a href="https://github.com/Microsoft/TypeScript/issues/26018" rel="nofollow noreferrer">https://github.com/Microsoft/TypeScript/issues/26018</a> and was closed.
  Attempt to change <strong>"module": "commonjs"</strong> at tsconfig.json doesn't help.
  A lot of people wrote that <strong>the issue still actual</strong>.</p>
  
  <p>My project looks like this</p>
  
  <pre><code>|- doc-app
  |    |- &lt; many direcotiries used at tests.ts &gt;
  |    |- tests
  |          lus-tests.ts
  |          tsconfig.json
  |
  |- node_modules
  |- tsconfig.json
  </code></pre>
  
  <p>Note: node "v10.16.0"</p>
  
  <p>tsconfig.json <em>at tests direcory</em></p>
  
  <pre><code>{
    "compilerOptions": {
      "target": "es5",
      "declaration": true,
      "module": "commonjs",
      "moduleResolution": "node",
      "sourceMap": true,
      "emitDecoratorMetadata": true,
      "experimentalDecorators": true,
      "removeComments": false,
      "noImplicitAny": false,
      "suppressImplicitAnyIndexErrors": true,
      "lib": ["es6", "dom"],
      "typeRoots": [
        "node_modules/@types"
      ]
   },
   "awesomeTypescriptLoaderOptions": {
     "useWebpackText": true,
      "useTranspileModule": true,
      "doTypeCheck": true,
      "forkChecker": true
   },
   "include": [
     "./"
   ],
   "exclude": [
     "node_modules"
   ]
  }
  </code></pre>
  
  <p>useful part of package.json</p>
  
  <pre><code>"devDependencies": {
    "@types/chai": "4.1.7",
    "@types/mocha": "5.2.7",
    "@types/sinon": "7.0.13",
    ...
    "chai": "4.2.0",
    ...
    "mocha": "6.1.4",
    ...
    "sinon": "7.3.2",
    ...
    "ts-mocha": "6.0.0",
    "ts-node": "8.4.1",
    "typescript": "2.9.2", //if change it to "3.6.3" it dosen't help
  }
  </code></pre>
  
  <p>If i specify "module": "exnext" at the tsconfig.json, then error is</p>
  
  <pre><code>D:\nginx\ibdrweb\webapps\ibdr-document-2\doc-app\tests\lus-tests.ts:1
  import "mocha";
         ^^^^^^^
  
  SyntaxError: Unexpected string
      at Module._compile (internal/modules/cjs/loader.js:721:23)
  </code></pre>
  
  <p><strong><em>Note:</em></strong> import { Tools } from "@ShareUtils/tools"; Module "tools" in node_modules</p>