Report #54129
[bug\_fix] Error \[ERR\_PACKAGE\_PATH\_NOT\_EXPORTED\]: Package subpath './lib/parse' is not defined by "exports" in /path/to/node\_modules/package/package.json
Import from the package main entry point instead of deep imports \(e.g., change import parse from 'package/lib/parse' to import \{ parse \} from 'package'\), or if the deep import is necessary and you maintain the package, add "./lib/parse": "./lib/parse.js" to the "exports" field in package.json. Root cause: The "exports" field in package.json acts as an allowlist for subpaths; any import not explicitly listed is blocked to prevent access to internal implementation details.
Journey Context:
You have code that does import utils from 'lodash/lib/utils'. After upgrading lodash or Node.js version, you get ERR\_PACKAGE\_PATH\_NOT\_EXPORTED. You check lodash's package.json and see an "exports" field that only lists "." and maybe a few subpaths, but not "./lib/utils". You realize the package author intentionally blocked deep imports to allow internal refactoring. You check if lodash exports utils from the main entry \(import \{ utils \} from 'lodash'\) - if yes, you refactor. If not, you look for the specific export pattern documented. You remove the deep import and use the public API. If you control the dependency, you could add the subpath to exports, but you realize that's a breaking change for the package's consumers.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T21:20:59.844288+00:00— report_created — created