Because my nodejs project is written in ts, according to tsconfig. About compilerOptions in json. The sourceMap description of the options, need to be in

Json to enable the sourceMap option so that the debugger can display the original TS code during debugging:

So I did:

My launch.json is automatically generated when I select vscode’s built-in Nodejs debugger:

When you press F5 to start debugging, the DEBUG CONSOLE prints the following:

Server connection error in explicit SRC/controller/captcha in my code. The corresponding dist/controller/ts captcha. Js. Map file has unrecognized symbol ‘:’

This error will cause the debugger to fail to start the service.

Since the map file reported the error, TSC should not generate the map file. Set the sourceMap option in tsconfig.json to false

Ctrl+Shift+B perform the TSC: Watch task (see here) to compile the new Dist file. Note that the old ones are manually deleted before recompiling

Dist directory, otherwise those.map files still exist.

Then press F5 to start debugging, and the service will start normally:

However, when you start debugging, the DEBUG CONSOLE displays the following error message:

Could not read the source map file. Of course, because I didn’t have sourceMap generated at TSC.

The problem with not having a sourceMap file is that you can’t break the original TS code. The original TS code is full of these invalid breakpoints.

The break point must be typed in the JS file below dist.

In conjunction with the TSC :watch task to compile the ts changes in real time (click here to view related content), you can modify the ts source in vscode without restarting the service

To see the updated JS file under Dist, and then debug the interrupt point.