Skip to content

Line numbers in stack traces are wrong in Node v20 #2053

Open
@gthb

Description

@gthb

Search Terms

line numbers

Note that there is #1495, closed almost two years ago, long before Node v20 came out. I opened a new issue because (a) root causes are likely different even if the manifestation is similar, and (b) the way to reproduce is likely different as well, and (c) I can't reopen that old one anyway :) but the problem is clearly present today.

Expected Behavior

I expect line numbers in stack traces thrown from TypeScript code to match the actual line numbers in the file, when running under Node v20, as they do when running under Node v18 and v19.

Actual Behavior

When running under Node v20, line numbers in stack traces are wrong, appearing to be from the transpiled version of the module.

Steps to reproduce the problem

Run a TypeScript module in which an error is thrown. Observe that the line numbers in the stack trace of that error are incorrect when running in Node v20, but are correct when running in Node v18 or v19.

Minimal reproduction

TypeStrong/ts-node-repros#34

Specifications

  • ts-node version: v10.9.1
  • node version: v20.5.1
  • TypeScript version: v5.2.2
  • tsconfig.json, if you're using one:
{}
  • package.json:
{
  "type": "module",
  "dependencies": {
    "ts-node": "latest",
    "typescript": "latest"
  }
}
  • Operating system and version: macOS 13.5.1 (22G90)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions