node.js: Unexpected token {

后端 未结 1 1390
礼貌的吻别
礼貌的吻别 2020-12-19 03:30

So I have a unit test written for mocha using TypeScript. I am trying to run it using gulp (which doesn\'t really play a part here). I get the following exception:



        
相关标签:
1条回答
  • 2020-12-19 03:39

    Node doesn't fully support import yet or at least not by default, so errors will happen when importing using the import in that way.

    When using TypeScript you should use "module": "commonjs" in your compilerOptions, because that is what node.js uses. When compiled, TypeScript will convert all the imports to node supported require's.

    0 讨论(0)
提交回复
热议问题