Skip to content Skip to sidebar Skip to footer

Node.js: Unexpected Token {

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: (function (export

Solution 1:

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.


Post a Comment for "Node.js: Unexpected Token {"