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.

0

1 Answer 1

-1

This is what you would want:

class name {

 }

module.exports = name;
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.