Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Property args is not allowed in launch.json in vscode

I am just trying to add some basic configuration to my launch.json file in vscode, but I am getting an error as Property args is not allowed. Below is my configuration.

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "attach",
            "name": "index",         
            "args": [
                "src/index.ts"
            ],
            "cwd": "${workspaceFolder}"           
        }
    ],
    "compounds": []
}

enter image description here

like image 302
Sibeesh Venu Avatar asked Jun 24 '18 05:06

Sibeesh Venu


People also ask

How do I launch Vscode json?

To create a launch.json file, click the create a launch.json file link in the Run start view. If you go back to the File Explorer view (Ctrl+Shift+E), you'll see that VS Code has created a .vscode folder and added the launch.json file to your workspace.

What is args in launch json?

args. JSON array of command-line arguments to pass to the program when it is launched. Example ["arg1", "arg2"] . If you are escaping characters, you will need to double escape them. For example, ["{\\\"arg1\\\": true}"] will send {"arg1": true} to your application.

Where is the settings json file for Vscode?

Depending on your platform, the user settings file is located here: Windows %APPDATA%\Code\User\settings.json. macOS $HOME/Library/Application\ Support/Code/User/settings.json. Linux $HOME/.config/Code/User/settings.json.


1 Answers

That was a silly mistake. According to this doc

VS Code debuggers typically support launching a program in debug mode or attaching to an already running program in debug mode. Depending on the request (attach or launch) different attributes are required and VS Code's launch.json validation and suggestions should help with that.

So when I changed my request to launch from attach, everything was perfect. Only the request type launch supports the configuration args.

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "index",         
            "args": [
                "src/index.ts"
            ],
            "cwd": "${workspaceFolder}"           
        }
    ],
    "compounds": []
}
like image 166
Sibeesh Venu Avatar answered Oct 19 '22 09:10

Sibeesh Venu