[Debug] How to Debug a NestJs Backend using the Chrome Dev Tools

TO debug NestJS code with Chrome dev tool, we can run:

node --inspect-brk dist/rest-api/src/main.js

TO make it easier for us running this later, we can do:

"start:debug": "tsc-watch -p tsconfig.build.json --onSuccess \"node --inspect-brk dist/rest-api/src/main.js\"",

After running this script, you cannot see the endpoint running, this is becasue we need to attach chrome dev tool.

To do that, open a new tab in Chrome,

chrome://inspect

THis helps to attach the chrome dev tool to our NestJS backend.

Then we can reopen the endpoint in tab, we can do the normal debugging as we did in Front end.

猜你喜欢

转载自www.cnblogs.com/Answer1215/p/11792532.html