* 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)
| 1602 | * @returns {void|string|undefined} |
| 1603 | */ |
| 1604 | function 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. |
no test coverage detected
searching dependent graphs…