ERR_PACKAGE_PATH_NOT_EXPORTED
node
module_error
ai_generated
true
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './X' is not defined by exports
ID: node/err-package-json-invalid
88%Fix Rate
90%Confidence
50Evidence
2023-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 20 | active | — | — | — |
Root Cause
Package exports field doesn't expose this subpath. Library changed its exports in a new version.
genericWorkarounds
-
92% success Check library changelog for the new import path after the update
Check library changelog for the new import path after the update
-
85% success Pin to the previous version that exposed this subpath
npm install library@previous-version # Or in package.json: "library": "2.x" (pin to major version)
Sources: https://docs.npmjs.com/cli/v10/commands/npm-install
-
90% success Use the library's public API instead of deep imports
// Old: import X from 'lib/internal/x' // New: import { X } from 'lib'
Dead Ends
Common approaches that don't work:
-
Patch package.json exports field in node_modules
85% fail
Changes will be lost on next npm install
-
Use require() to bypass exports restriction
60% fail
Only works for CJS packages and may break in future
Error Chain
Frequently confused with: