Skip to content

Line numbers in error stack not changing #268

@vladpazych

Description

@vladpazych

In my code generator project, I watch directory and on each change do require.cache cleaning and rerequire modules from that directory.

And I use stack to implement one important feature.

var stack = new Error().stack;
var stackLines = stack.match(/[^\r\n]+/g);
console.log(stackLines[1]) 

>>>
at Object.<anonymous> (/Workspace/gener/data.js:1:13)

Rerequire works fine, because each time file changes, I see that console.log, meaning file is actually rerequired.

But if I move var stack = new Error().stack; down by 5 lines, I still get:

at Object.<anonymous> (/Workspace/gener/data.js:1:13) // I get
at Object.<anonymous> (/Workspace/gener/data.js:6:13) // I should get

If I do same experiment in pure js and node - it works fine.

So the only moving part between working version and not working version is node server.js and ts-node server.js

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions