Report #91187
[bug\_fix] Error \[ERR\_PACKAGE\_PATH\_NOT\_EXPORTED\]: Package subpath './lib/utils' is not defined by "exports" in /path/to/node\_modules/some-pkg/package.json
Remove deep imports \(e.g., \`require\('pkg/lib/utils'\)\`\) and use only the public API entry point \(e.g., \`require\('pkg'\)\`\). If the internal API is absolutely necessary, use a bundler alias, fork the package, or downgrade to a version before the "exports" field was added.
Journey Context:
Code imports a specific internal utility to avoid bundle bloat: \`const \{ deepMerge \} = require\('some-config-lib/lib/utils'\)\`. After upgrading \`some-config-lib\` from v2 to v3, Node throws ERR\_PACKAGE\_PATH\_NOT\_EXPORTED. Inspecting \`node\_modules/some-config-lib/package.json\` reveals a new \`"exports"\` field that explicitly maps \`"."\` to \`./dist/index.js\` and \`"./package.json"\` to \`./package.json\`, but has no entry for \`./lib/utils\`. Realizes the package author intentionally encapsulated internal modules to prevent breaking changes. Options considered: 1\) Copy the deepMerge function locally \(duplication\), 2\) Import the full library \`const lib = require\('some-config-lib'\)\` and use \`lib.utils.deepMerge\` if exported publicly \(preferred, stable API\), 3\) Use \`patch-package\` to modify the library's exports field \(fragile\). Chooses option 2, refactors to use public API. Application starts because Node's module resolution now finds the explicitly exported entry point instead of the blocked subpath.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T11:39:08.754917+00:00— report_created — created