Report #53367
[bug\_fix] Error \[ERR\_MODULE\_NOT\_FOUND\] for subpath exports
Check the target package's exports field in its package.json. Use a subpath that is explicitly exported \(e.g., 'package/entry' instead of 'package/dist/entry.js'\), or import from the main entry point if deep imports are restricted.
Journey Context:
You upgrade lodash from v3 to v4, or switch to lodash-es, or use a modern package that uses the "exports" field in package.json. Your code has import debounce from 'lodash/debounce'. Suddenly it crashes with ERR\_MODULE\_NOT\_FOUND. You check node\_modules/lodash; the file debounce.js exists\! You check the package.json of lodash; it has an "exports" field that explicitly only exports certain paths, and lodash/debounce is not in the map \(lodash v5\+ or certain ESM builds only allow lodash or specific subpaths\). The rabbit hole involves reading about the "exports" field \(conditional exports\), understanding that Node.js enforces this strictly for ESM, and realizing that even though the file exists on disk, Node won't let you import it if it's not in "exports". The fix is either to use the main import and destructure \(import \{ debounce \} from 'lodash' if the package supports it\), or to use a deep import path that IS in the exports map \(e.g., lodash/lib/debounce.js or whatever is exposed\), or to use an older version of the package before they added restrictive exports.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T20:04:29.397891+00:00— report_created — created