Skip to content

Commit 07e16a1

Browse files
committed
module: fix error reporting when commonjs requires an ES module
1 parent 5d4fee8 commit 07e16a1

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/internal/modules/cjs/loader.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ const {
5656
StringPrototypeCharCodeAt,
5757
StringPrototypeEndsWith,
5858
StringPrototypeIndexOf,
59+
StringPrototypeLastIndexOf,
5960
StringPrototypeRepeat,
6061
StringPrototypeSlice,
6162
StringPrototypeSplit,
@@ -1649,7 +1650,7 @@ function loadTS(module, filename) {
16491650

16501651
function reconstructErrorStack(err, parentPath, parentSource) {
16511652
const errLine = StringPrototypeSplit(
1652-
StringPrototypeSlice(err.stack, StringPrototypeIndexOf(
1653+
StringPrototypeSlice(err.stack, StringPrototypeLastIndexOf(
16531654
err.stack, ' at ')), '\n', 1)[0];
16541655
const { 1: line, 2: col } =
16551656
RegExpPrototypeExec(/(\d+):(\d+)\)/, errLine) || [];

0 commit comments

Comments
 (0)