Report #6109
[bug\_fix] TypeScript error: Cannot find module './utils' or its corresponding type declarations
Use .js extension in TypeScript ESM imports: import \{ x \} from './utils.js' and enable moduleResolution: 'bundler' or 'node16'
Journey Context:
Using TypeScript 4.7\+ with "type": "module". Writing import \{ helper \} from './utils' where utils.ts exists. TypeScript complains it cannot find the module. Tried './utils.ts', TypeScript accepts it but emitted JS keeps .ts extension which is wrong. Realized that in TypeScript ESM, you must write the import with .js extension: './utils.js', even though the source file is .ts. TypeScript's module resolution handles this mapping. Also needed to set "moduleResolution": "node16" or "bundler" in tsconfig.json for modern resolution. Without this, TypeScript fails to resolve the specifiers correctly.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T23:12:11.349420+00:00— report_created — created