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: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.
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.