Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between args and runtimeArgs in VSCode's launch.json?

Tags:

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.

like image 227
pushkin Avatar asked Feb 13 '17 15:02

pushkin


People also ask

What is launch json outFiles?

"outFiles" is expected to specify all generated files via a glob patterns, not just one.

What is JavaScript debug Terminal?

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.

How to debug a Nodejs application?

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.


1 Answers

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.

like image 131
Gama11 Avatar answered Oct 14 '22 07:10

Gama11