How to define CLI args before running the app in Launch.json ? (Node.js)

Viewed 17

I am trying to specify argument for running the node app. Somehow ,

    role_id=123 secret_id=123 node app

Works. But,

    node app role_id=123 secret_id=123

Doesn't work and gives me missing args error.

When I add these args to launch.json in VsCode , the program runs in the later way , as shown in VSCode Terminal Screenshot. How to run the program in the way , that the args are defined before running node app.

Launch.json looks like this :

{
    "version": "0.2.0",
    "configurations": [
        {
            "args": ["role_id=123", "secret_id=123", "NODE_ENV=test"],
            "type": "node",
            "request": "launch",
            "name": "DEBUG NODE APP",
            "program": "${workspaceFolder}/app.js",
        }
    ]
}
0 Answers
Related