-
-
Notifications
You must be signed in to change notification settings - Fork 535
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
Breakpoints don't work #778
Comments
@neustart I am in the same boat, on Mac. I have been tracing and trying just about every suggestion from #537, to no avail. I've also tried all sorts of tsconfig.json tweaks (such as inline source maps, outDir configuration), etc etc. It seems ts-node is just not wired up to be able to inspect the files, but I have not yet figured out why the debugger can attach then have no files to debug. Would love to figure this out! |
https://blog.june07.com/nim-custom-devtools-url explains a solution to this. Often the problem is due to breaking changes with DevTools. Using NiM allows you to lock the DevTools version whilst still using the most recent version of Chrome. |
Facing the same issue with the VS Code debugger. |
@levrik Did you try https://chrome.google.com/webstore/detail/nodejs-v8-inspector-manag/gnhhdgbaldcilmgcpfddgdbkhjohddkj |
@june07 I want breakpoints directly in VS Code... not an external solution. |
I also have this problem. Cannot hit breakpoints in VSCode using |
@cspotcode Thanks for your suggestion. Unfortunately, I did not have |
@rnegron bummer, it was worth a shot. Do you have a minimum reproducible example for us to try on our machines? |
@cspotcode I attempted to make a very minimal version of the affected repository's structure with a contrived example here: https://github.com/rnegron/ts-node-breakpoints-example However, breakpoints are working in that repository, even though they are not perfect since the debugger seems to halt on the line after the breakpoint. You will notice that the code is in JavaScript, since we are currently experimenting with a migration to TypeScript. Obviously, the real repository is much larger and there are a lot of module imports happening. Could that have anything to do with it? |
@rnegron Without a reproduction, I really don't know. I would guess that it's not about the size of the repository; it's about something specific that is happening in your real repo that is not in your reproduction. |
@cspotcode I will continue to debug this and report back if I find anything. Thanks! |
Are you using docker? If so, this comment helped to resolve this issue for me: microsoft/vscode-recipes#187 (comment) This shows that hitting breakpoints should work as well, so there might be something else going on with your actual repository that prevents breakpoints from being hit. info on my setup (sharing all of it just to be sure)I'm using vscode 1.42.0, node 13.8 (from dockerhub), ts-node 8.6.2 My app is started using the following line:
my tsconfig.json looks like the following: {
"compilerOptions": {
"esModuleInterop": true,
"strict": true,
"lib": ["ES2020"],
"types": ["node"],
"sourceMap": true
},
"files": ["./src/**/*"]
} my launch.json looks like the following: {
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "Docker: Attach to Node",
"sourceMapPathOverrides": {
"/usr/src/app/*": "${workspaceRoot}/*"
},
"port": 9229,
"protocol": "inspector" // probably not needed here since vscode should resolve this automatically, even when using ts-node (Haven't tested it yet though)
}
]
}``` |
I have an issue with ts-node not stopping on breakpoints in VS Code, but only if those breakpoints are in the files imported by the main file. If the main file has any breakpoints after the import statements, breakpoints inside imported code are triggered just fine. |
@romankozak As far as I can tell, if I want breakpoint to be triggered in imported files, I need to add a breakpoint to my main file before code from any imported files is called. This appears to be a VSCode bug. Everything works correctly in Chrome/Edge DevTools. I created a branch where I have a code sample with the debugger configured. Hopefully using this as a reference makes it a little bit easier to discuss what works and what doesn't. https://github.com/TypeStrong/ts-node-repros/tree/vscode-debugging |
@cspotcode thank you for the sample. I think you are right that this is VSCode bug. I've tried to workaround by compiling the typescript code with tsc first and then running it - with this approach, breakpoints were triggered correctly in the test project, but in the other project only part of the time. |
I wonder if it does not repro with mocha because mocha loads all the files
first, then fires the callbacks later. Perhaps this delay gives the
debugger enough time to register breakpoints.
…On Tue, May 12, 2020 at 4:48 PM Roman Kozak ***@***.***> wrote:
@cspotcode <https://github.com/cspotcode> thank you for the sample. I
think you are right that this is VSCode bug. I've tried to workaround by
compiling the typescript code with tsc first and then running it - with
this approach, breakpoints were triggered correctly in the test project,
but in the other project only part of the time.
This doesn't repro when running code thru mocha test with ts-node, so this
could an alternative approach to having breakpoint in the main file for VS
Code users.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#778 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAC35OCB3PDYFT54J2KA4CDRRGYZFANCNFSM4GWLAV7A>
.
|
Also happens with IntelliJ / Webstorm (2020.2+) + Mocha. Oddly, the breakpoints in Mocha test files will be hit, but all subsequent required TS files do not get breakpoints hit. Spent days tweaking configs, trying different combos, etc. to no avail. I switch to JEST + TS-JEST and don't have any of the same issues. |
@Gameghostify Thanks, it worked for me as also found here: https://medium.com/@dupski/debug-typescript-in-vs-code-without-compiling-using-ts-node-9d1f4f9a94a |
I was also having this issue, but I solved it with this: Below is my before/after launch.json Before
After
I removed I don't know why, but now vscode debugger hits breakpoints correctly |
Thank you for sharing your configuration. Do you have a few minutes to compare your configuration against the one in our documentation? If our documentation is incorrect, incomplete, or confusing, I would definitely like to make the necessary corrections or improvements to help other users. |
Forgot to link our docs: https://typestrong.org/ts-node/docs/recipes/visual-studio-code |
I have tested the debug configuration in our docs to confirm that it works with breakpoints. I tweaked our documentation here: #1466 Closing as I believe no further action is required. Improvements to our documentation can be submitted as pull requests, and Discussions can be used for more open-ended discussion and tech support around debugging. |
Hi guys, I faced a very strange problem. Let me know if this repo is the wrong place to post this question because I really don't realize what kind of problem is this.
I have two working PC and one of them stop breaking on the breakpoints in one day. Another PC works properly the same as before.
I tried to reinstall Node.Js, ts-node and then even hard reset for windows (I use Windows) but without any success.
Then I thought that probably issue in my project and I tried to clone hello world project from google tutorial and I found that I still can't debug with it!
So basically I successfully run an app on my port but breakpoint won't hit. This stop working in VS Code, in WebStorm and even Chrome debugger.
This is how I run an app:
"C:\Program Files\nodejs\node.exe" --inspect --require ts-node/register C:\Projects\node-typescript-starter-master\src\index.ts
Then I opened dev tools from chrome and I see this:
Then I pressed "inspect" and I see message in console:
Debugger attached. Debugger listening on ws://127.0.0.1:9229/8bae9408-867c-4278-9148-b6c90b35a8ae For help, see: https://nodejs.org/en/docs/inspector Debugger attached.
This is the next window. Seems like I missing any files overhere.
DevTools
Does this mean that something is wrong with my file mapping ?
Please, let me any suggestion what can be a problem.
The text was updated successfully, but these errors were encountered: