Node ERR_PACKAGE_PATH_NOT_EXPORTED in CI - Fix the Exports Map Subpath
ERR_PACKAGE_PATH_NOT_EXPORTED means a package defines an exports map, and you imported a subpath the map does not expose, so the deep import is blocked.
What this error means
A node import throws Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined or Package subpath ... is not defined by exports, for a deep import into a dependency.
node
node:internal/modules/esm/resolve:282
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/internal'
is not defined by "exports" in
/home/runner/work/app/app/node_modules/some-lib/package.jsonCommon causes
Importing a path the exports map does not list
The package restricts which files are importable via exports, and the deep path you used is not among them.
Relying on an internal file path that became private
A package added an exports map in a new version, locking down internals the code previously reached into.
How to fix it
Import a supported entry point
- Check the package exports map for the public subpaths.
- Import from a documented entry instead of the internal path.
JavaScript
import { thing } from 'some-lib';
// not: import { thing } from 'some-lib/lib/internal';How to prevent it
- Import only documented entry points, avoid reaching into a package internals, and review exports-map changes when upgrading dependencies.
Related guides
Node "Cannot find package 'X' imported from" in CI - Fix the ESM Package ResolutionFix the Node.js "Cannot find package X imported from" ESM error in CI by installing the dependency or correct…
Node ERR_MODULE_NOT_FOUND on ESM Import in CI - Fix Specifier ResolutionFix the Node.js ERR_MODULE_NOT_FOUND error in CI by adding the missing file extension or correcting the ESM i…
Node ERR_UNSUPPORTED_DIR_IMPORT in CI - Import a File, Not a DirectoryFix the Node.js ERR_UNSUPPORTED_DIR_IMPORT error in CI by importing an explicit file path instead of a direct…