diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/internal/errors.js | 2 | ||||
-rw-r--r-- | lib/internal/modules/cjs/loader.js | 7 |
2 files changed, 5 insertions, 4 deletions
diff --git a/lib/internal/errors.js b/lib/internal/errors.js index cc60bf5ab8..6e3bfb29c0 100644 --- a/lib/internal/errors.js +++ b/lib/internal/errors.js @@ -1104,8 +1104,6 @@ E('ERR_OUT_OF_RANGE', msg += ` It must be ${range}. Received ${received}`; return msg; }, RangeError); -E('ERR_PATH_NOT_EXPORTED', - 'Package exports for \'%s\' do not define a \'%s\' subpath', Error); E('ERR_REQUIRE_ESM', 'Must use import to load ES Module: %s', Error); E('ERR_SCRIPT_EXECUTION_INTERRUPTED', 'Script execution was interrupted by `SIGINT`', Error); diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js index bdc0122590..95b56e0852 100644 --- a/lib/internal/modules/cjs/loader.js +++ b/lib/internal/modules/cjs/loader.js @@ -60,7 +60,6 @@ const { compileFunction } = internalBinding('contextify'); const { ERR_INVALID_ARG_VALUE, ERR_INVALID_OPT_VALUE, - ERR_PATH_NOT_EXPORTED, ERR_REQUIRE_ESM } = require('internal/errors').codes; const { validateString } = require('internal/validators'); @@ -377,7 +376,11 @@ function resolveExports(nmPath, request, absoluteRequest) { return fileURLToPath(resolved); } } - throw new ERR_PATH_NOT_EXPORTED(basePath, mappingKey); + // eslint-disable-next-line no-restricted-syntax + const e = new Error(`Package exports for '${basePath}' do not define ` + + `a '${mappingKey}' subpath`); + e.code = 'MODULE_NOT_FOUND'; + throw e; } } |