Report #101509
[bug\_fix] TS1479 / ERR\_REQUIRE\_ESM / ERR\_MODULE\_NOT\_FOUND when importing a modern ESM-only package from a TypeScript project using moduleResolution 'node' or CommonJS emit
Set both compilerOptions.module and compilerOptions.moduleResolution to 'nodenext' \(or 'node16'\), add "type": "module" to package.json if you want ESM .ts files, use .mts/.cts extensions to force a per-file format, and include file extensions on relative imports in ESM files.
Journey Context:
You install a popular new dependency that ships only ESM \("type": "module"\). With module: esnext and moduleResolution: node, tsc reports TS1479: the current file is a CommonJS module whose imports will produce 'require' calls, but the referenced file is an ECMAScript module. You try module: ES2022 and get ERR\_REQUIRE\_ESM at runtime. The root cause is that 'node10' resolution assumes everything resolves like old CommonJS and does not model Node's dual module system. Switching to nodenext makes TypeScript mirror Node's format detection via package.json type and file extensions, so emit and type checking match what Node will actually do.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-07T04:58:36.808570+00:00— report_created — created