Skip to content

Commit a565f22

Browse files
module: avoid ERR_INVALID_ARG_TYPE when findPackageJSON is stumped
1 parent 32ff100 commit a565f22

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

lib/internal/modules/package_json_reader.js

+3
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ function findPackageJSON(specifier, base = 'data:') {
296296
return packageJSONPath;
297297
}
298298

299+
/** @type {string} */
299300
let resolvedTarget;
300301
cascadedLoader ??= require('internal/modules/esm/loader').getOrInitializeCascadedLoader();
301302

@@ -309,6 +310,8 @@ function findPackageJSON(specifier, base = 'data:') {
309310
}
310311
}
311312

313+
if (resolvedTarget == null) { return; }
314+
312315
const pkg = getNearestParentPackageJSON(fileURLToPath(resolvedTarget));
313316

314317
return pkg?.path;

0 commit comments

Comments
 (0)