nest: Unable to debug app in VS CODE
I’m submitting a…
[ ] Regression
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.
Current behavior
starting with npm run:debug, the client receives a connection refused response and console log on nest.js stops:
MBPFUEKOR:silk-server fuekor$ npm run start:debug
> silk-server@0.0.1 start:debug /projects/silk-erp/silk-server
> nodemon --config nodemon-debug.json
[nodemon] 1.18.4
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: /projects/silk-erp/silk-server/src/**/*
[nodemon] starting `node --inspect-brk -r ts-node/register src/main.ts`
Debugger listening on ws://127.0.0.1:9229/4db21849-1288-418b-8eae-4acdddd22e01
For help see https://nodejs.org/en/docs/inspector
Debug points set but not reached.
Expected behavior
Debugging code 😃
Minimal reproduction of the problem with instructions
My app uses logging, typeorm and swagger so far, but problem can be replicated with any standard app from the examples without modification.
What is the motivation / use case for changing the behavior?
Environment
Nest version: 5.1.0
For Tooling issues:
- Node version: 9.21, also with 8.9.x
- Platform:
MAC
Others:
VS CODE 1.27.2
When using debugger start from within VS CODE, the following appears in the debugger console:
```
Debugger listening on ws://127.0.0.1:14272/47b9aa5f-32ce-4800-85f2-c503fb6bb7ce
Debugger attached.
```
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 18
First, remove your
launch.jsonfile.Then open the command
ctrl + shift + pand search forDebug: Toggle auto attach, press enter.Make sure that you’ve got the following at the bottom of VSC:
Add a
nodemon-debug.jsonfile at the root of the project with the following content:Add that line in your package.json script section:
"start:debug": "nodemon --config nodemon-debug.json"And now just run
npm run start:debug, should be good 👍Credit: Took a lot of that from https://github.com/nestjs/typescript-starter
i will supplement @maxime1992 answer. according to Auto Attach docs
npm run start:debugshould be executed from VS Code’s Integrated TerminalNvm, I solved this by putting the generated graphql schema ts file in a separate folder and exclude the folder from
nodemon, thanks anyway.Even running npm run start:debug on VS Code integrated terminal, the debug it’s not working.
When i run the debug task with the vs code npm plugin it works.
My nodemon-debug.json
Good Morning, sorry i was out of the office last week, but i tried and it works like a charm now using maxime1992’s approach. Thanks for the help Best Regards from Manila Ralph.