diff --git a/lib/internal/util/inspect.js b/lib/internal/util/inspect.js index 814e5bf0f37cd4..ca3227dea43c99 100644 --- a/lib/internal/util/inspect.js +++ b/lib/internal/util/inspect.js @@ -1311,7 +1311,7 @@ function formatError(err, constructor, tag, ctx, keys) { let nodeModule; newStack += '\n'; let pos = 0; - while (nodeModule = nodeModulesRegExp.exec(line)) { + while ((nodeModule = nodeModulesRegExp.exec(line)) !== null) { // '/node_modules/'.length === 14 newStack += line.slice(pos, nodeModule.index + 14); newStack += ctx.stylize(nodeModule[1], 'module');