What is the difference between args
and runtimeArgs
in launch.json?
// Optional arguments passed to the runtime executable "runtimeArgs": [] // Command line arguments passed to the program "args": []
Is the program not the same thing as the runtime executable?
Extra information and motivation behind the question:
I am developing a nodejs application. In my package.json
, I have a start
script:
"start": "electron ./src/Main/main.js arg2"
, and in my app code, I access process.argv[2]
which gets me arg2
, so when I run npm start
, my app works as intended.
When I run the app from VSCode, however it doesn't, and the reason was that I wasn't supplying any additional arguments in launch.json
. Where should I put those arguments? process.argv
seems to contains the arguments provided in either args
or runtimeArgs
though it also sticks in some --debug-brk
argument, which I don't want.
I want to be able to use process.argv
consistently when I run the app from the command line (npm start
) or start it from VSCode.
"outFiles" is expected to specify all generated files via a glob patterns, not just one.
JavaScript Debug Terminal# In a similar way to auto attach, the JavaScript Debug Terminal will automatically debug any Node. js process you run in it. You can create a Debug Terminal by running the Debug: Create JavaScript Debug Terminal command from the Command Palette ( kbs(workbench.
Open the starting file (typically index. js ), activate the Run and Debug pane, and click the Run and Debug Node. js (F5) button. The debugging screen is similar to Chrome DevTools with a Variables, Watch, Call stack, Loaded scripts, and Breakpoints list.
I think this is mostly explained in the Node debugging docs:
Instead of launching the Node.js program directly with node, you can use 'npm' scripts or other task runner tools directly from a launch configuration:
- Any program available on the PATH (for example 'npm', 'mocha', 'gulp', etc.) can be used for the runtimeExecutable attribute [...]
runtimeExecutable
is not the program you want to debug, but the executable used to run it. So it appears that runtimeArgs
is to runtimeExecutable
as args
is to program
.
If you're interested in how it works in detail, here's the relevant part of the debugAdapter.ts
implementation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With