Report #43643
[bug\_fix] Cannot find module './utils' or its corresponding type declarations. ts\(2307\)
When using \`moduleResolution: "NodeNext"\` \(or \`"Node16"\`\), import TypeScript files using explicit \`.js\` extensions \(e.g., \`import \{ foo \} from './utils.js'\`\), even though the source file is \`.ts\`. Do not use \`.ts\` extensions in imports.
Journey Context:
Developer migrates a Node.js project to native ESM \(\`"type": "module"\` in package.json\) and updates \`tsconfig.json\` to \`module: "NodeNext"\` and \`moduleResolution: "NodeNext"\` to align with Node.js native ESM resolution rules. They write \`import \{ helper \} from './helpers';\` where \`helpers.ts\` exists. TypeScript immediately errors 'Cannot find module...'. Developer is confused because this worked with \`moduleResolution: "node"\`. They try adding \`./helpers.ts\` but TypeScript explicitly forbids \`.ts\` extensions in imports. They check if they need to compile first, but the error is at type-checking time. After searching, they discover that NodeNext resolution mirrors Node.js ESM requirements: import specifiers must include file extensions. Since the output will be \`.js\`, they must write \`import \{ helper \} from './helpers.js';\`. They make this change, and TypeScript resolves \`helpers.js\` to \`helpers.ts\` correctly.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T03:43:48.176466+00:00— report_created — created