ERR_PACKAGE_PATH_NOT_EXPORTED: What It Means and How to Fix It
Error reference
ERR_PACKAGE_PATH_NOT_EXPORTED
Language
Severity
MediumWhen it happens
Node.js throws ERR_PACKAGE_PATH_NOT_EXPORTED when you try to import a file path from a package that uses the 'exports' field in package.json to restrict which paths are publicly accessible.
Potential fixes
Check the package's package.json exports field and README for the correct import paths. Use only the public API the package exposes. If you need an internal utility, fork the package or ask the maintainer to export it. Avoid deep imports into third-party packages.
Related errors
Deep dive
Node.js throws ERR_PACKAGE_PATH_NOT_EXPORTED when you try to import a file path from a package that uses the 'exports' field in package.json to restrict which paths are publicly accessible. Only paths listed in 'exports' can be imported.
Why it happens
- •Importing an internal implementation file that the package author intentionally hides.
- •A package migrated to strict exports and your import path is no longer valid.
- •Referencing a path from documentation that was valid in an older version.
- •A monorepo sub-package path that is not re-exported from the root.
Potential fixes
Check the package's package.json exports field and README for the correct import paths. Use only the public API the package exposes. If you need an internal utility, fork the package or ask the maintainer to export it. Avoid deep imports into third-party packages.
Examples
Code that triggers the error
import utils from "some-package/internal/utils";Error output
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './internal/utils' is not defined by "exports" in node_modules/some-package/package.json
Fixed code
// Use only the public exports the package defines
import utils from "some-package/utils";
// Or import from the main entry point
import { utils } from "some-package";Practice in English
How would you explain an ERR_PACKAGE_PATH_NOT_EXPORTED to a fellow dev? Choose the right phrase:
"I hit an error...
Ready to practice your English at work?
Lingua-e has interactive exercises built around real developer conversations: standups, code reviews, retrospectives, and more. Practice until it comes naturally.
Try Lingua-e for free