On my Ubuntu 16.04 I use IntelliJ IDEA ultima 2017.2 together with node v6.11.2 and npm v3.10.10 and want to debug a node.js application, which has the following package.json start entry:
"start:" "npm-run-all --parallel serve-static open-static"
According to the console output and this similar SO question I need to add $NODE_DEBUG_OPTION as first parameter (for node) to avoid the Connection refused error. Obvioulsy, I have tried
- to add $NODE_DEBUG_OPTION in the Run/Debug configuration as Arguments
- and as Node options
which resulted in calls like
node npm-cli.js run start-debug --scripts-prepend-node-path=auto $NODE_DEBUG_OPTION
and
node $NODE_DEBUG_OPTION npm-cli.js run start-debug --scripts-prepend-node-path=auto
in each case $NODE_DEBUG_OPTION is not resolved and node treats it like a non-existing file.
I have also tried to add variable directly in package.json like
"start:" "npm-run-all $NODE_DEBUG_OPTION --parallel serve-static open-static"
which also results in a Cannot find module .../$NODE_DEBUG_OPTION error.
So, how can I pass this option in order to debug that thingy in IntelliJ IDEA?
Thanks
adding
$NODE_DEBUG_OPTION
topackage.json
manually is the only way to debug the application started via npm script, because you have to make sure that Node.js is started with appropriate debug options (--debug-brk
,--inspect-brk
, etc), and the IDE can't control the way child processes are spawned - it can only pass options to the main process when starting it. But this option has to be passed to Node.js - not to npm-cli.js, npm-run-all, etc. If npm-run-all is an npm script that starts the app you'd like to debug with node.js, you need to modify this script accordingly, like:If your task runs a shell script, that, in turn, runs your app with node.js, you need to modify a shell script... The goal is to start the node process with debug options