Understanding esModuleInterop in tsconfig.json: How to Fix Import of CommonJS Modules in TypeScript
Hello everyone! I'm new to TypeScript and encountered a confusing issue while setting up my project. I have a Node.js project and I'm using the popular `express` library. I installed it via npm and also installed the types (`@types/express`). My `tsconfig.json` file looks like this:
```json
{
"compilerOptions": {
"target": "ES2020",
"module": "commonjs",
"outDir": "./dist",
"rootDir": "./src",
"strict": true
}
}
```
When I try to import express like this:
```typescript
import express from 'express';
```
TypeScript throws an error: `Module '"/path/to/node_modules/@types/express/index"' has no default export.` or something like `This module is declared with 'export =' and can only be used with a default import when using the 'esModuleInterop' option.`