Report #51205
[bug\_fix] Error \[ERR\_PACKAGE\_PATH\_NOT\_EXPORTED\]: Package subpath './lib/util' is not defined by "exports"
Import only the subpaths explicitly defined in the package's exports field \(check the package docs\), or import from the package root if that is exported. Do not deep-require internal modules.
Journey Context:
A developer upgrades uuid from v8 to v9 in their Node.js application. Their code contains const util = require\('uuid/lib/util'\). After the upgrade, the app crashes with ERR\_PACKAGE\_PATH\_NOT\_EXPORTED. The developer inspects node\_modules/uuid and confirms that lib/util.js exists on disk, but the package.json now contains an "exports" field that explicitly only exposes "./package.json", ".", and "./v1", etc., but NOT "./lib/util". The developer initially files a bug report thinking it's a regression, but the maintainer points out that deep imports into internal paths were never part of the public API. Reading the Node.js packages documentation, the developer learns that the "exports" field acts as an access control list, preventing consumers from relying on internal file structures that may change. The fix involves refactoring the code to use only the documented public exports \(e.g., const \{ v4 \} = require\('uuid'\)\), ensuring compatibility with the package's defined API surface.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T16:26:01.200082+00:00— report_created — created