Trying to implement a module following the official handbook, I get this error message:
Uncaught ReferenceError: exports is not defined
at app.js:2
But nowhere in my code do I ever use the name exports
.
How can I fix this?
let a = 2;
let b:number = 3;
import Person = require ('./mods/module-1');
export class Person {
constructor(){
console.log('Person Class');
}
}
export default Person;
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"noImplicitAny": false,
"sourceMap": true,
"outDir": "scripts/"
},
"exclude": [
"node_modules"
]
}
Few other Solutions for this issue
<script>var exports = {};</script>