Report #11622
[bug\_fix] TS1192: Module 'node:fs' has no default export.
Enable \`esModuleInterop: true\` in tsconfig.json \(which implies \`allowSyntheticDefaultImports\`\), allowing default import syntax for CommonJS modules that use \`module.exports = ...\`, because without this flag TypeScript strictly enforces ES module semantics where \`import fs from 'fs'\` requires a \`default\` export which CommonJS modules do not natively provide.
Journey Context:
Developer copies a code snippet from a blog post: \`import fs from 'fs'; const data = fs.readFileSync\('file.txt'\);\`. They paste it into a new TypeScript file. TypeScript shows error TS1192: "Module 'fs' has no default export." Developer is confused because the blog said this works. They try \`import \* as fs from 'fs';\` and that works, but they prefer the default import syntax. They check their \`tsconfig.json\` and see it's a basic config without \`esModuleInterop\`. They search the error and find that Node.js built-in modules are CommonJS. To use default import syntax with CJS modules, they must enable \`esModuleInterop\`. They add \`"esModuleInterop": true\` to their tsconfig. The error disappears because TypeScript now synthesizes a default export for the CommonJS module, matching the interop behavior of Babel and Webpack.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T13:47:57.049911+00:00— report_created — created