Categories
TypeScript Answers

How to fix the ‘TypeScript ReferenceError: exports is not defined’ with TypeScript?

Spread the love

To fix the ‘TypeScript ReferenceError: exports is not defined’ with TypeScript, we can set the module option to 'es6' is tsconfig.json.

For instance, we write

{
  //...
  "compilerOptions": {
    "module": "es6",
    "target": "es5"
  }
  //...
}

to set compilerOptions.module to 'es6' to fix the ‘TypeScript ReferenceError: exports is not defined’ error thrown during compilation.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *