nestjs / nest

A progressive Node.js framework for building efficient, scalable, and enterprise-grade server-side applications with TypeScript/JavaScript 🚀
https://nestjs.com
MIT License
66.9k stars 7.55k forks source link

Debug webstorm #993

Closed david23539 closed 6 years ago

david23539 commented 6 years ago

I'm submitting a...


[ ] Regression 
[ ] Bug report
[ ] Feature request
[x] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

Webstorm can't debug with nest's command npm run start

Minimal reproduction of the problem with instructions

Webstorm's breakpoints don't work in debug mode

Environment


Nest version: 5.0.0


For Tooling issues:
- Node version: 10.7.0  
- Platform:   Windows 10 - webstorm 2018.1.5
- NPM version: 6.1.0

kamilmysliwiec commented 6 years ago

It's not related to the framework itself. Btw, see here https://github.com/nestjs/typescript-starter/issues/30

kherel commented 5 years ago

I'm using mac, but It's probably be very similar. If you are using nest.js cli with nodemon-debug.json "exec": "node --inspect-brk -r ts-node/register -r tsconfig-paths/register src/main.ts" you only need to specify the port, witch by default is 9229

plus run npm/yarn script start:debug before debugger launch

screen shot 2019-02-06 at 10 12 43 pm
deyvedvm commented 5 years ago

I was able to run debug int WebStorm after changing the path of the main.ts file:

Before: "exec": "node --inspect-brk -r ts-node/register -r tsconfig-paths/register src/main.ts"

After: "exec": "node --inspect-brk -r ts-node/register -r tsconfig-paths/register ./src/main.ts"

I followed the Jetbrains tutorial: https://www.jetbrains.com/help/webstorm/running-and-debugging-node-js.html

AmazingTurtle commented 5 years ago

What about NODE_DEBUG_OPTION? Webstorm is telling me to use that instead when debugging a npm script. Would love to see that working with nodemon.

david23539 commented 5 years ago

thanks

AmazingTurtle commented 5 years ago

I found a solution to debug nestjs in webstorm. Create a new script in your package.json. In webstorm you can just right-click -> debug in the npm scripts window. I use the following script for that:

...
"start:debug:webstorm": "node %NODE_DEBUG_OPTION% -r ts-node/register -r tsconfig-paths/register src/main.ts",
...
murilozilli commented 4 years ago

@AmazingTurtle I get this after that Error: Cannot find module '/home/murilo/project/%NODE_DEBUG_OPTION%'

beaulac commented 4 years ago

@murilozilli That example is for windows, on Linux/Mac it should be: "node $NODE_DEBUG_OPTION -r ts-node/register -r tsconfig-paths/register src/main.ts"

coverboy commented 4 years ago

Selection_036

sprour commented 4 years ago

You can install dev dependency @nestjs/cli, then put the following settings: Node parameters: Full path/node_modules/@nestjs/cli/bin/nets.js start --watch Working directory: Project root Js file: src/main.ts

lock[bot] commented 4 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.