MCPcopy Index your code
hub / github.com/nodejs/node / finalizeEsmResolution

Function finalizeEsmResolution

lib/internal/modules/cjs/loader.js:1604–1616  ·  view source on GitHub ↗

* Finishes resolving an ES module specifier into an absolute file path. * @param {string} resolved The resolved module specifier * @param {string} parentPath The path of the parent module * @param {string} pkgPath The path of the package.json file * @throws {ERR_INVALID_MODULE_SPECIFIER} If the

(resolved, parentPath, pkgPath)

Source from the content-addressed store, hash-verified

1602 * @returns {void|string|undefined}
1603 */
1604function finalizeEsmResolution(resolved, parentPath, pkgPath) {
1605 const { encodedSepRegEx } = require('internal/modules/esm/resolve');
1606 if (RegExpPrototypeExec(encodedSepRegEx, resolved) !== null) {
1607 throw new ERR_INVALID_MODULE_SPECIFIER(
1608 resolved, 'must not include encoded "/" or "\\" characters', parentPath);
1609 }
1610 const filename = fileURLToPath(resolved);
1611 const actual = tryFile(filename);
1612 if (actual) {
1613 return actual;
1614 }
1615 throw createEsmNotFoundErr(filename, pkgPath);
1616}
1617
1618/**
1619 * Creates an error object for when a requested ES module cannot be found.

Callers 3

resolveExpansionFunction · 0.85
resolveExportsFunction · 0.85
loader.jsFile · 0.85

Calls 4

fileURLToPathFunction · 0.85
createEsmNotFoundErrFunction · 0.85
tryFileFunction · 0.70
requireFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…