diff --git a/lib/internal/util.js b/lib/internal/util.js index e9345d56609e0a..e8763d204ee348 100644 --- a/lib/internal/util.js +++ b/lib/internal/util.js @@ -37,6 +37,7 @@ const { SafeWeakRef, StringPrototypeIncludes, StringPrototypeReplace, + StringPrototypeStartsWith, StringPrototypeToLowerCase, StringPrototypeToUpperCase, Symbol, @@ -515,11 +516,14 @@ function isInsideNodeModules() { if (ArrayIsArray(stack)) { for (const frame of stack) { const filename = frame.getFileName(); - // If a filename does not start with / or contain \, - // it's likely from Node.js core. + if ( - filename[0] !== '/' && - StringPrototypeIncludes(filename, '\\') === false + filename == null || + StringPrototypeStartsWith(filename, 'node:') === true || + ( + filename[0] !== '/' && + StringPrototypeIncludes(filename, '\\') === false + ) ) { continue; }