mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00
esm: improve commonjs hint on module not found
Adds hint when module specifier is a file URL. PR-URL: https://github.com/nodejs/node/pull/33220 Fixes: https://github.com/nodejs/node/issues/33219 Reviewed-By: Guy Bedford <guybedford@gmail.com>
This commit is contained in:
parent
985e9c5fe5
commit
1cb80d1e05
1 changed files with 3 additions and 0 deletions
|
@ -758,6 +758,9 @@ function defaultResolve(specifier, context = {}, defaultResolveUnused) {
|
|||
// resolved CommonJS module
|
||||
if (error.code === 'ERR_MODULE_NOT_FOUND' ||
|
||||
error.code === 'ERR_UNSUPPORTED_DIR_IMPORT') {
|
||||
if (StringPrototypeStartsWith(specifier, 'file://')) {
|
||||
specifier = fileURLToPath(specifier);
|
||||
}
|
||||
const found = resolveAsCommonJS(specifier, parentURL);
|
||||
if (found) {
|
||||
// Modify the stack and message string to include the hint
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue