TypeScript Error: ReferenceError: exports is not defined during build
Hi everyone! I'm new to TypeScript and encountered an issue when trying to compile and run my project. I'm using Node.js (version 18) and TypeScript (version 5.0). Here's my simple code:
```typescript
// math.ts
export function add(a: number, b: number): number {
return a + b;
}
export const PI = 3.14;
```
```typescript
// main.ts
import { add, PI } from './math';
console.log(add(2, 3));
console.log(PI);
```
I compiled the code with the command `tsc main.ts` and got the files `math.js` and `main.js`. When I run `node main.js`, I get the following error:
```
ReferenceError: exports is not defined
at Object. (/path/to/main.js:2:23)
```
In the generated JS files, I see the use of `exports.add = ...` and `exports.PI = ...`. I've read that this is