Search code examples
node.jsvisual-studio-codecommand-line-arguments

In Visual Studio Code, how to pass arguments in launch.json


In Visual Studio Code, in the launch.json file that launches the app I'm writing, how do I add command line arguments?


Solution

  • As described in the documentation, you need to use the args attribute. E.g.

    {
        // Use IntelliSense to learn about possible attributes.
        // Hover to view descriptions of existing attributes.
        // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
        "version": "0.2.0",
        "configurations": [
            {
                "type": "node",
                "request": "launch",
                "name": "Debug App",
                "program": "${workspaceFolder}/main.js",
                "args": ["arg1", "arg2", "arg3"]
            }
        ]
    }