Skip to content

Commit

Permalink
module: avoid ERR_INVALID_ARG_TYPE when findPackageJSON is stumped
Browse files Browse the repository at this point in the history
  • Loading branch information
JakobJingleheimer committed Nov 11, 2024
1 parent 32ff100 commit a565f22
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/internal/modules/package_json_reader.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ function findPackageJSON(specifier, base = 'data:') {
return packageJSONPath;
}

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

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

if (resolvedTarget == null) { return; }

const pkg = getNearestParentPackageJSON(fileURLToPath(resolvedTarget));

return pkg?.path;
Expand Down

0 comments on commit a565f22

Please sign in to comment.