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.