1

Node supports ES6 from node v4.6 upwards, if i'm not mistaken. Creating ES6 modules works fine until I need to import and export these modules, I then get the following error(s):

export class Helper {
^^^^^^
SyntaxError: Unexpected token export

I feel like I'm missing something.

SOLUTION THAT WORKED FOR ME

in your tsconfig.json file, add the property

{"module": "commonjs"}

this will keep the ES6 syntax and behaviour but import/export using the ES5 method.

Altus
  • 1,315
  • 3
  • 11
  • 19

1 Answers1

-1

This is what you would want:

class name {

 }

module.exports = name;
Amiga500
  • 5,874
  • 10
  • 64
  • 117