GeezerVison is showing github.com — module: exports error as MODULE_NOT_FOUND · jmdfm/node@452b393
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: doc/api/errors.md -7Lines changed: 0 additions & 7 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -1599,13 +1599,6 @@ compiled with ICU support. | 1599 | 1599 |
| 1600 | 1600 | A given value is out of the accepted range. | 1601 | 1601 |
| 1602 | | -<a id="ERR_PATH_NOT_EXPORTED"></a> | 1603 | | -### ERR_PATH_NOT_EXPORTED | 1604 | | - | 1605 | | -> Stability: 1 - Experimental | 1606 | | -
| 1607 | | -An attempt was made to load a protected path from a package using `exports`. | 1608 | | - | 1609 | 1602 | <a id="ERR_REQUIRE_ESM"></a> | 1610 | 1603 | ### ERR_REQUIRE_ESM | 1611 | 1604 |
| |
Collapse file Copy file name to clipboardExpand all lines: doc/api/modules.md +2-2Lines changed: 2 additions & 2 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -223,10 +223,10 @@ RESOLVE_BARE_SPECIFIER(DIR, X) | 223 | 223 | a. Parse DIR/name/package.json, and look for "exports" field. | 224 | 224 | b. If "exports" is null or undefined, GOTO 3. | 225 | 225 | c. Find the longest key in "exports" that the subpath starts with. | 226 | | - d. If no such key can be found, throw "not exported". | | 226 | + d. If no such key can be found, throw "not found". | 227 | 227 | e. If the key matches the subpath entirely, return DIR/name/${exports[key]}. | 228 | 228 | f. If either the key or exports[key] do not end with a slash (`/`), | 229 | | - throw "not exported". | | 229 | + throw "not found". | 230 | 230 | g. Return DIR/name/${exports[key]}${subpath.slice(key.length)}. | 231 | 231 | 3. return DIR/X | 232 | 232 | ``` | |
Collapse file Copy file name to clipboardExpand all lines: lib/internal/errors.js -2Lines changed: 0 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1104,8 +1104,6 @@ E('ERR_OUT_OF_RANGE', | 1104 | 1104 | msg += ` It must be ${range}. Received ${received}`; | 1105 | 1105 | return msg; | 1106 | 1106 | }, RangeError); | 1107 | | -E('ERR_PATH_NOT_EXPORTED', | 1108 | | - 'Package exports for \'%s\' do not define a \'%s\' subpath', Error); | 1109 | 1107 | E('ERR_REQUIRE_ESM', 'Must use import to load ES Module: %s', Error); | 1110 | 1108 | E('ERR_SCRIPT_EXECUTION_INTERRUPTED', | 1111 | 1109 | 'Script execution was interrupted by `SIGINT`', Error); | |
Collapse file Copy file name to clipboardExpand all lines: lib/internal/modules/cjs/loader.js +5-2Lines changed: 5 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -60,7 +60,6 @@ const { compileFunction } = internalBinding('contextify'); | 60 | 60 | const { | 61 | 61 | ERR_INVALID_ARG_VALUE, | 62 | 62 | ERR_INVALID_OPT_VALUE, | 63 | | - ERR_PATH_NOT_EXPORTED, | 64 | 63 | ERR_REQUIRE_ESM | 65 | 64 | } = require('internal/errors').codes; | 66 | 65 | const { validateString } = require('internal/validators'); | @@ -377,7 +376,11 @@ function resolveExports(nmPath, request, absoluteRequest) { | 377 | 376 | return fileURLToPath(resolved); | 378 | 377 | } | 379 | 378 | } | 380 | | - throw new ERR_PATH_NOT_EXPORTED(basePath, mappingKey); | | 379 | + // eslint-disable-next-line no-restricted-syntax | | 380 | + const e = new Error(`Package exports for '${basePath}' do not define ` + | | 381 | + `a '${mappingKey}' subpath`); | | 382 | + e.code = 'MODULE_NOT_FOUND'; | | 383 | + throw e; | 381 | 384 | } | 382 | 385 | } | 383 | 386 |
| |
Collapse file Copy file name to clipboardExpand all lines: src/module_wrap.cc +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -859,7 +859,7 @@ Maybe<URL> PackageExportsResolve(Environment* env, | 859 | 859 | std::string msg = "Package exports for '" + | 860 | 860 | URL(".", pjson_url).ToFilePath() + "' do not define a '" + pkg_subpath + | 861 | 861 | "' subpath, imported from " + base.ToFilePath(); | 862 | | - node::THROW_ERR_PATH_NOT_EXPORTED(env, msg.c_str()); | | 862 | + node::THROW_ERR_MODULE_NOT_FOUND(env, msg.c_str()); | 863 | 863 | return Nothing<URL>(); | 864 | 864 | } | 865 | 865 |
| |
Collapse file Copy file name to clipboardExpand all lines: src/node_errors.h -1Lines changed: 0 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -53,7 +53,6 @@ void PrintErrorString(const char* format, ...); | 53 | 53 | V(ERR_MISSING_PLATFORM_FOR_WORKER, Error) \ | 54 | 54 | V(ERR_MODULE_NOT_FOUND, Error) \ | 55 | 55 | V(ERR_OUT_OF_RANGE, RangeError) \ | 56 | | - V(ERR_PATH_NOT_EXPORTED, Error) \ | 57 | 56 | V(ERR_SCRIPT_EXECUTION_INTERRUPTED, Error) \ | 58 | 57 | V(ERR_SCRIPT_EXECUTION_TIMEOUT, Error) \ | 59 | 58 | V(ERR_STRING_TOO_LONG, Error) \ | |
Collapse file Copy file name to clipboardExpand all lines: test/es-module/test-esm-exports.mjs +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -29,15 +29,15 @@ import { requireFixture, importFixture } from '../fixtures/pkgexports.mjs'; | 29 | 29 |
| 30 | 30 | // There's no such export - so there's nothing to do. | 31 | 31 | loadFixture('pkgexports/missing').catch(mustCall((err) => { | 32 | | - strictEqual(err.code, 'ERR_PATH_NOT_EXPORTED'); | | 32 | + strictEqual(err.code, (isRequire ? '' : 'ERR_') + 'MODULE_NOT_FOUND'); | 33 | 33 | assertStartsWith(err.message, 'Package exports'); | 34 | 34 | assertIncludes(err.message, 'do not define a \'./missing\' subpath'); | 35 | 35 | })); | 36 | 36 |
| 37 | 37 | // The file exists but isn't exported. The exports is a number which counts | 38 | 38 | // as a non-null value without any properties, just like `{}`. | 39 | 39 | loadFixture('pkgexports-number/hidden.js').catch(mustCall((err) => { | 40 | | - strictEqual(err.code, 'ERR_PATH_NOT_EXPORTED'); | | 40 | + strictEqual(err.code, (isRequire ? '' : 'ERR_') + 'MODULE_NOT_FOUND'); | 41 | 41 | assertStartsWith(err.message, 'Package exports'); | 42 | 42 | assertIncludes(err.message, 'do not define a \'./hidden.js\' subpath'); | 43 | 43 | })); | @@ -57,7 +57,7 @@ import { requireFixture, importFixture } from '../fixtures/pkgexports.mjs'; | 57 | 57 | // Even though 'pkgexports/sub/asdf.js' works, alternate "path-like" variants | 58 | 58 | // do not to prevent confusion and accidental loopholes. | 59 | 59 | loadFixture('pkgexports/sub/./../asdf.js').catch(mustCall((err) => { | 60 | | - strictEqual(err.code, 'ERR_PATH_NOT_EXPORTED'); | | 60 | + strictEqual(err.code, (isRequire ? '' : 'ERR_') + 'MODULE_NOT_FOUND'); | 61 | 61 | assertStartsWith(err.message, 'Package exports'); | 62 | 62 | assertIncludes(err.message, | 63 | 63 | 'do not define a \'./sub/./../asdf.js\' subpath'); | |
|