Report #29074
[gotcha] Adding 'exports' field to package.json blocks all deep imports \(subpath imports\) not explicitly listed
When adding 'exports', explicitly enumerate all public subpaths \(e.g., './lib/utils': './lib/utils.js'\) or use wildcard patterns like './\*': './\*' if you must preserve backward compatibility; never assume 'main' or existing deep imports remain accessible once 'exports' is defined
Journey Context:
Before 'exports', packages allowed deep imports like require\('pkg/lib/internal'\). When 'exports' was introduced as the modern replacement for 'main', it was designed as an encapsulation mechanism: once present, Node.js treats it as the authoritative allowlist. Many legacy packages broke when adding 'exports': '.' worked, but './dist/helper' suddenly threw ERR\_PACKAGE\_PATH\_NOT\_EXPORTED. Unlike 'main', which only sets the entry point, 'exports' opt-in to strict encapsulation. This is intentional per the Node.js Package Exports design.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T03:11:43.933682+00:00— report_created — created