Node.js server debuging with WebStorm (grunt) - node.js

I'm using grunt to launch my server with livereload and other tasks.
I've followed this and this post to run my grunt tasks.
It's working but I can't debug properly (when I set some breakpoints, there aren't hit)
When I launch the script, here is what I got:
As you can see the debugger appears in a 2nd tab, but it's not doing anything. (even if it says it's connected successfully).
To debug my app I've to stop this 2nd tab, and run a remote debugger... Anyway to fix this?
Additional info: The server is run in another process. If I run it in the same process as grunt, there are no issues.

What Node.js version do you use? In 0.10.x the child process occupies the same port as a master process, so debugging won't work by default. Related ticket: https://github.com/joyent/node/issues/5318. Can you check if it works for you using Node.js ersion >= 0.11.4? Also, what Grunt tasks are being used?

As mentioned by lena, the issue seems to be fixed in WebStorm 8.

Related

Nuclide debugger with node and babel?

I've been trying to use Nuclide/Atom to launch and debug a unit test that uses Babel and ES6+ code. The launch config looks like this:
Node runs the unit test as if I had run it from the command-line, and does not stop at my breakpoints. If I use the same invocation at the command-line with --inspect-brk I can debug correctly (with sourcemaps) from the chrome-devtools url in Chrome. Is there a way to make this work? I can't really "attach" since the unit tests are, and should be, a straight-shot script execution.
Nuclide currently does not support the new v8 Inspector protocol for debugging. You will need to use --debug flag to debug with Nuclide. Note, however, that the old debugger protocol has been removed from Node.js starting with Node.js 8.0.
PS. You can attach to a running Node.js process with Nuclide debugger just fine - just start your tests with node --debug --debug-brk ... and then attach the debugger from Nuclide. The test process will be stopped at first line, allowing you to resume execution at your own convenience.

Debugging node app in WebStorm when run from gulp

I am using webstorm 10.0.2 and have used the bangular yeoman template to generate a project. I can run the gulp commands via the gulp window, and I can set a breakpoint in the gulpfile.js and it will hit it, but I can't seem to get it to hit a breakpoint in my server.js
It looks to me like the gulp file is launching another instance of node and thus when you do "debug" from webstorm you are just debugging the gulp.
I also tried with another project using yo hottowel but get the same thing - I am unable to debug the actual application through webstorm.
Can anybody tell me how to configure webstorm so that I can debug the actual server side node code but still use the gulp build tool?
I contacted JetBrains support back in May 2015 and their response was:
It seems this cannot be done quickly. In short, the problem is that serve-dev task starts new process (nodemon) that takes app.js
There is no workaround how to debug such spawned processes right now. We would really appreciate if you'll submit a feature request about it in our YouTrack: https://youtrack.jetbrains.com/issues/WEB
The only way you can try to avoid it - try to create a separate task that will run app.js directly without nodemon process and debug this task instead.
It seems the best option is to use https://www.npmjs.com/package/gulp-node-inspector

Use nodemon or supervisor to reload only the files without restart all the server - WebStorm

I just took a look to this tutorial: How can I run nodemon from within WebStorm?
I'm wondering how reload only the files updated and don't restart the entire server instance.
I'm wondering also if it's possible to don't break a debug breakpoint, because for the moment the entire server is restarted and if I'm following instruction step by step using the debogguer, I lost the track.
By the way, there are my ways to use them with webstorm, it's particularly tricky with supervisor. Because it needs to get the app.js and everything as parameters.
Supervisor: https://docs.google.com/file/d/0ByzbHcAxmCyvTGdHOWJSTTYzNWs/edit
Nodemon: https://docs.google.com/file/d/0ByzbHcAxmCyvdVQ3azFhSlV0dEU/edit
You can use modules like hotswap to reload files when they change.
It can cause memory leaks and other stuff, but it's working fine for development.

How to debug Node with Grunt from webstorm

I have been using grunt in my project and I wanted to be able to debug the code using web storm.
How do I open a debug port in node JS?
When trying to use the remote debug a nodeJS option the IDE hangs on trying to debug...
When trying to control node from within webstorm I followed this question
I am getting:
\nodejs\node.exe \grunt server
Process finished with exit code 99.
Any ideas?
Try removing the 'server' application parameter.

Webstorm: debugging node.js sails app

I'm having a hard time finding the right combination of settings to allow me to debug my node.js sails application in webstorm.
These are the settings I've tried using, both configurations work (as in sails starts) but none is stopping at breakpoints.
If I go to the breakpoints menu and turn on 'Any exception enabled' - it does stop for exceptions, but never hits my breakpoints.
Any ideas? I'm on webstorm 7.0.1 and Node 0.10.18 / Sails 0.9.7
You don't need the --debug in node parameters. Here is my config and i am on 7.0.1 and node 0.10.4
Let me know if it helped. Also, you are hitting the bug to run debug right?
Also, can you please invalidate caches/ restart? That helps sometimes. Here is a snapshot in the file menu.
I had the same problem and simply installed sails local to the project and everything worked fine. Not sure why the configuration can't resolve the globally installed sails as that is the error I was getting, but the local install works fine. I should investigate further, but I'm lazy :)
When you open a new project on WebStorm, it detects the package.json file and it will ask you to install the dependencies locally. After that, by using the configuration mentioned before (not necessarily by using sails lift but using app.js directly instead), you can debug you application from WebStorm. Another way to do it, is by using this tool, that works like a charm: https://github.com/node-inspector/node-inspector :)

Resources