TS1259
error TS1259: Module can only be default-imported using the ‘esModuleInterop’ flag
Broken Code ❌
main.tstsconfig.json1 2 3 4 5 6 7 8 9 10 11 12 13
| { "compilerOptions": { "lib": [ "dom", "es6" ], "module": "commonjs", "moduleResolution": "node", "outDir": "dist", "rootDir": "src", "target": "es6" } }
|
Fixed Code ✔️
tsconfig.json1 2 3 4 5 6 7 8 9 10 11 12 13 14
| { "compilerOptions": { "esModuleInterop": true, "lib": [ "dom", "es6" ], "module": "commonjs", "moduleResolution": "node", "outDir": "dist", "rootDir": "src", "target": "es6" } }
|
Note: You can enable the ‘esModuleInterop’ flag also via the CLI:
1
| tsc main.ts --esModuleInterop
|