Node.js Debugging - Webstorm 2017.1.2

Hi All,

I'm working on a Node.js project in Webstorm 2017.1.2 and my debugging has completely stopped working. This happened after I flushed and reinstalled all my project dependencies due to an error during a build to a production server. I'm using a combination of nodemon, npm config (referring to the run/debug configurations dialog) and npm scripts. Originally my configuration was this:

// run/debug configurations dialog box

Configuration type: npm

Command: run

Scripts: dev

Arguments: --debug-brk

// package.json file

"dev": "nodemon %NODE_DEBUG_OPTION% src/index.js --exec \"node -r dotenv/config -r babel-register\"",

This used to work perfectly but now I'm receving the following error when I run the config:

[nodemon] starting `node -r dotenv/config -r babel-register --debug-brk=49865 --expose_debug_as=v8debug src/index.js`
node: bad option: --expose_debug_as=v8debug
[nodemon] app crashed - waiting for file changes before starting...

I've now done some research and found out that node debugger was deprecated in version 7 of node. What baffles me is that this configuration was working well beyond the deprecation of that feature. I've tried following the guides in the documentation but none of them seem to yield what I am looking for. This incident also raises a number of questions:

How could this configuration have been working long after it was broken?

Possible answer, I know it says in the docs as a user of WebStorm I don't have to worry about using the right command to debug and that the tool will just figure out the right one to use via the version of Node in the project. This does not seem to be the case. If you look at the previous error I can see it's trying to use --debug-brk which passes --debug-brk as the node debug option but I've also tried --inspect-brk but guess what? It passes --debug-brk when I do that:

[nodemon] starting `node -r dotenv/config -r babel-register --debug-brk=50051 --expose_debug_as=v8debug src/index.js`
[nodemon] app crashed - waiting for file changes before starting...
node: bad option: --expose_debug_as=v8debug

If I pass nothing the app starts but you cannot debug it. So the documentation is false then.

Given that node.js has a new debugging protocol how could WS have been working at all beyond v6?

https://www.jetbrains.com/help/webstorm/running-and-debugging-node-js.html - The local debugging tutorial here did get some results if I passed the --inpsect flag but it still give me this output and the only thing that really started working is the check symbol on the breakpoints, but it doesn't actually stop on the breakpoints:

"C:\Program Files\nodejs\node.exe" --debug-brk --inspect=50529 C:\projects\xapi-router-service\src\index.js
Debugger listening on ws://127.0.0.1:50529/54f2d662-e524-4b1a-bc28-f5050e1dfae7
For help see https://nodejs.org/en/docs/inspector
(node:37720) [DEP0062] DeprecationWarning: `node --inspect --debug-brk` is deprecated. Please use `node --inspect-brk` instead.
Listening on port 8080

Can someone shed some light on this and make sense of it all? All I want is my local debugging back. This has got to be the most confusing and frustrating process just to debug some code. If there is anything I can do to help improve the documentation on this please do let me know! The IDE and debugging JS has become more complex than just using node by itself with a text editor, I don't see a point in continuing to use Webstorm if it's going to start costing me time rather than saving it.

0
1 comment

You must have used different Node.js version. https://youtrack.jetbrains.com/issue/WEB-27123 is fixed in 2017.2, full support for Node 8 is available since 2017.3. Pleese consider upgrading - or downgrade Node to v.6

0

Please sign in to leave a comment.