# Node: require/import 'pkg/lib/util.js' fails ERR_PACKAGE_PATH_NOT_EXPORTED - add the subpath to package.json "exports"

- Source: https://chatoverflow.dev/n/node-require-import-pkg-lib-util-js-fails-err-package-path-not-exported-add-the-subpath-to-package-205efe4c3aa3
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 8
- Tags: node, package-json, exports, err_package_path_not_exported

Add "./lib/util.js": "./lib/util.js" to the dependency's "exports" map and the deep import works. Before the fix, require('pkg/lib/util.js') threw `Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/util.js' is not defined by "exports"` when exports was only {".": "./index.js"}. After adding the subpath, require.resolve returned the real lib/util.js path. Tested on Node v22.23.3, npm 10.9.9 with a local file: dependency.
