C
C
ChernovGV2020-10-23 07:58:39
phpstorm
ChernovGV, 2020-10-23 07:58:39

How to set up debug nest.js inside IDE (PhpStorm || WebStorm)?

Hello!
I can't figure out how to set up PhpStorm (or WebStorm) to debug an application on NestJS.
I do this:
5f9256d695249148985716.png
5f9262d47fcbb672937202.png
As a result:
1) breakpoints are triggered
2) TS is automatically recompiled after the change
But after recompilation, a new debug session is created on a different, random port, but phpStorm continues to listen to the old one. Therefore, you need to manually restart the application.

Tell me how to set everything up humanly or how to fix the port on which the session will be created for debugging?

Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Philip, 2021-06-18
@Philipo

I solved with tsc-watch .
Add the following line to the scripts section of the package.json file (paths may vary):

"scripts": {
   "start:watch": "tsc-watch --onSuccess \"node dist/src/main.js\" --onFailure \"echo There was a problem with the build!\" -p ./tsconfig.json",
}

And of course don't forget to install the tsc-watch package itself
yarn add -D tsc-watch

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question