Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support --inspect #218

Closed
jonaskello opened this issue Oct 11, 2016 · 7 comments
Closed

Support --inspect #218

jonaskello opened this issue Oct 11, 2016 · 7 comments

Comments

@jonaskello
Copy link
Contributor

It is possible to run node --inspect test1.js and get a link to debug in chrome. See here.

Would it be possible to add support for ts-node --inspect test1.ts and get similar support?

Seems babel-node has support for this.

@jonaskello
Copy link
Contributor Author

That was fast, thanks! :-)

I did a quick test to verify like this:

test1.ts

console.log("hello");

setTimeout(() => 
    console.log("goodbye"), 
    20000);

ts-node --inspect test1.ts

I then open the provided debug URL in chrome within 20 seconds and can see the test1.ts file in the tree. I set a breakpoint on the goodbye line and it hits. So far it works great. However for me the sourcemaps don't get loaded correctly. When I open the test1.ts in DevTools I see the transpiled JS code and at the bottom I see //# sourceMappingURL=/var/folders/x9/80kc..... I checked for this file and it exists as well. Chrome is also displaying an information notice at the top of the file saying "Source maps detected". I'm no expert at sourcdemaps so I don't know what this all means but to me it looks as if all the pieces are in place but it is still not working. Maybe I should open a separate issue for this?

@blakeembrey
Copy link
Member

I'm happy to keep the discussion here, just because I have no idea how to fix that. It seems like I'd be going into the Chrome debugger territory. Does babel's source maps work? Is there possibly some flag or config you need to change to use the source map? The source maps definitely work in node through source-map-support, so perhaps this is something else?

@blakeembrey
Copy link
Member

Actually, see nodejs/node#8369 perhaps?

@jonaskello
Copy link
Contributor Author

Yes, it looks to me as ts-node is providing all that should be needed so that nodejs issue is probably what is causing it. I will subscribe to that and see what they come up with. Thanks again for adding the option.

@quantuminformation
Copy link

I just tried debugging vitest test in chrome
` "test:debug": "npx ts-node --inspect node_modules/vitest/dist/index.js"

however I get Error: Unknown or unexpected option: --inspect

@reduxdj
Copy link

reduxdj commented Apr 1, 2022

try this: npx ts-node index.js node --inspect-brk -r node_modules/vitest/dist/index.js

@cspotcode
Copy link
Collaborator

node options need to be passed to node, not to ts-node. There are a few options for this. One is using NODE_OPTIONS with the ts-node CLI. Another is node <node options here> --require ts-node/register or node <node options here> --loader ts-node/esm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants