ts-node: Breakpoints don't work
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.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 6
- Comments: 23
I was also having this issue, but I solved it with this:
Below is my before/after launch.json (using VSCode 1.59.0)
Before
After
I removed
program
property and moved its value intoargs
and it worked.I don’t know why, but now vscode debugger hits breakpoints correctly
Are you using docker? If so, this comment helped to resolve this issue for me:
https://github.com/Microsoft/vscode-recipes/issues/187#issuecomment-483814483
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:
export TS_NODE_PROJECT=tsconfig.json; export TS_NODE_FILES=true; node --nolazy --inspect=0.0.0.0:9229 -r ts-node/register ./src/index.ts
my tsconfig.json looks like the following:
my launch.json looks like the following:
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 notifications@github.com wrote:
Facing the same issue with the VS Code debugger. It just doesn’t hit breakpoints.
@Neustart I am in the same boat, on Mac. I have been tracing and trying just about every suggestion from https://github.com/TypeStrong/ts-node/issues/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!