From b0a6ade3bd1be0bd2c60bf8d7a8652cdc75a4e59 Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Fri, 30 Jul 2021 10:36:53 -0700 Subject: [PATCH] module: fix ERR_REQUIRE_ESM error for null frames PR-URL: https://github.com/nodejs/node/pull/39593 Reviewed-By: Bradley Farias Reviewed-By: Rich Trott --- lib/internal/errors.js | 2 +- test/fixtures/es-modules/cjs-esm.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/internal/errors.js b/lib/internal/errors.js index 1853315ba5c7bd..25b847b140a6df 100644 --- a/lib/internal/errors.js +++ b/lib/internal/errors.js @@ -808,7 +808,7 @@ function hideInternalStackFrames(error) { if (typeof stackFrames === 'object') { frames = ArrayPrototypeFilter( stackFrames, - (frm) => !StringPrototypeStartsWith(frm.getFileName(), + (frm) => !StringPrototypeStartsWith(frm.getFileName() || '', 'node:internal') ); } diff --git a/test/fixtures/es-modules/cjs-esm.js b/test/fixtures/es-modules/cjs-esm.js index 3599178996800d..482ee18454e1ae 100644 --- a/test/fixtures/es-modules/cjs-esm.js +++ b/test/fixtures/es-modules/cjs-esm.js @@ -1 +1 @@ -require('./package-type-module/cjs.js'); +eval("require('./package-type-module/cjs.js')");