GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — module: exports error as MODULE_NOT_FOUND · jmdfm/node@452b393

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • doc/api
    • errors.md
    • modules.md
  • lib/internal
    • errors.js
    • modules/cjs
      • loader.js
  • src
    • module_wrap.cc
    • node_errors.h
  • test/es-module
    • test-esm-exports.mjs
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎doc/api/errors.md‎

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 numberDiff line numberDiff line change
@@ -1599,13 +1599,6 @@ compiled with ICU support.
15991599

16001600
A given value is out of the accepted range.
16011601

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-
16091602
<a id="ERR_REQUIRE_ESM"></a>
16101603
### ERR_REQUIRE_ESM
16111604

Collapse file

‎doc/api/modules.md‎

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 numberDiff line numberDiff line change
@@ -223,10 +223,10 @@ RESOLVE_BARE_SPECIFIER(DIR, X)
223223
a. Parse DIR/name/package.json, and look for "exports" field.
224224
b. If "exports" is null or undefined, GOTO 3.
225225
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".
227227
e. If the key matches the subpath entirely, return DIR/name/${exports[key]}.
228228
f. If either the key or exports[key] do not end with a slash (`/`),
229-
throw "not exported".
229+
throw "not found".
230230
g. Return DIR/name/${exports[key]}${subpath.slice(key.length)}.
231231
3. return DIR/X
232232
```
Collapse file

‎lib/internal/errors.js‎

Copy file name to clipboardExpand all lines: lib/internal/errors.js
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1104,8 +1104,6 @@ E('ERR_OUT_OF_RANGE',
11041104
msg += ` It must be ${range}. Received ${received}`;
11051105
return msg;
11061106
}, RangeError);
1107-
E('ERR_PATH_NOT_EXPORTED',
1108-
'Package exports for \'%s\' do not define a \'%s\' subpath', Error);
11091107
E('ERR_REQUIRE_ESM', 'Must use import to load ES Module: %s', Error);
11101108
E('ERR_SCRIPT_EXECUTION_INTERRUPTED',
11111109
'Script execution was interrupted by `SIGINT`', Error);
Collapse file

‎lib/internal/modules/cjs/loader.js‎

Copy file name to clipboardExpand all lines: lib/internal/modules/cjs/loader.js
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ const { compileFunction } = internalBinding('contextify');
6060
const {
6161
ERR_INVALID_ARG_VALUE,
6262
ERR_INVALID_OPT_VALUE,
63-
ERR_PATH_NOT_EXPORTED,
6463
ERR_REQUIRE_ESM
6564
} = require('internal/errors').codes;
6665
const { validateString } = require('internal/validators');
@@ -377,7 +376,11 @@ function resolveExports(nmPath, request, absoluteRequest) {
377376
return fileURLToPath(resolved);
378377
}
379378
}
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;
381384
}
382385
}
383386

Collapse file

‎src/module_wrap.cc‎

Copy file name to clipboardExpand all lines: src/module_wrap.cc
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,7 @@ Maybe<URL> PackageExportsResolve(Environment* env,
859859
std::string msg = "Package exports for '" +
860860
URL(".", pjson_url).ToFilePath() + "' do not define a '" + pkg_subpath +
861861
"' 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());
863863
return Nothing<URL>();
864864
}
865865

Collapse file

‎src/node_errors.h‎

Copy file name to clipboardExpand all lines: src/node_errors.h
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ void PrintErrorString(const char* format, ...);
5353
V(ERR_MISSING_PLATFORM_FOR_WORKER, Error) \
5454
V(ERR_MODULE_NOT_FOUND, Error) \
5555
V(ERR_OUT_OF_RANGE, RangeError) \
56-
V(ERR_PATH_NOT_EXPORTED, Error) \
5756
V(ERR_SCRIPT_EXECUTION_INTERRUPTED, Error) \
5857
V(ERR_SCRIPT_EXECUTION_TIMEOUT, Error) \
5958
V(ERR_STRING_TOO_LONG, Error) \
Collapse file

‎test/es-module/test-esm-exports.mjs‎

Copy file name to clipboardExpand all lines: test/es-module/test-esm-exports.mjs
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ import { requireFixture, importFixture } from '../fixtures/pkgexports.mjs';
2929

3030
// There's no such export - so there's nothing to do.
3131
loadFixture('pkgexports/missing').catch(mustCall((err) => {
32-
strictEqual(err.code, 'ERR_PATH_NOT_EXPORTED');
32+
strictEqual(err.code, (isRequire ? '' : 'ERR_') + 'MODULE_NOT_FOUND');
3333
assertStartsWith(err.message, 'Package exports');
3434
assertIncludes(err.message, 'do not define a \'./missing\' subpath');
3535
}));
3636

3737
// The file exists but isn't exported. The exports is a number which counts
3838
// as a non-null value without any properties, just like `{}`.
3939
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');
4141
assertStartsWith(err.message, 'Package exports');
4242
assertIncludes(err.message, 'do not define a \'./hidden.js\' subpath');
4343
}));
@@ -57,7 +57,7 @@ import { requireFixture, importFixture } from '../fixtures/pkgexports.mjs';
5757
// Even though 'pkgexports/sub/asdf.js' works, alternate "path-like" variants
5858
// do not to prevent confusion and accidental loopholes.
5959
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');
6161
assertStartsWith(err.message, 'Package exports');
6262
assertIncludes(err.message,
6363
'do not define a \'./sub/./../asdf.js\' subpath');

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.