Report #71239
[bug\_fix] Cannot find module './utils' or its corresponding type declarations
When using \`moduleResolution\` set to \`Node16\` or \`NodeNext\`, import TypeScript files using the \`.js\` extension that the file will have at runtime: \`import \{ foo \} from './utils.js'\`. Do not use \`.ts\` extensions in the import path.
Journey Context:
You migrate a Node.js project to native ES Modules \("type": "module" in package.json\) and update tsconfig to \`"module": "Node16", "moduleResolution": "Node16"\`. You have a file \`utils.ts\` and import it as \`import \{ helper \} from './utils'\`. TypeScript immediately errors: "Cannot find module './utils'". You try \`from './utils.ts'\` and TypeScript is happy, but when you run the compiled JS, Node crashes with "Cannot find module...". You read the TypeScript handbook on ESM and realize that ES Module resolution in Node requires explicit file extensions, and TypeScript emulates this. Since the output file will be \`.js\`, you must write the import with \`.js\` even though the source is \`.ts\`.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T02:09:19.940389+00:00— report_created — created