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.
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
How to fix it
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.
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";Related errors
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