Unable to launch Debugging for a "npx" launched App in visual studio code
Asked Answered
P

1

8

I need to launch a particular .js file for execution, in this way:

  1. npx app.js launch.conf.js //for execution of scripts

  2. npx app.js debug.conf.js //for debugging the scripts

In my debug.conf.js contains

const config = {
  debug: true,
  execArgv: ['--inspect-brk'],
  maxInstances: 1,
  cucumberOpts: {
    timeout: 30 * 1000 * 4,
  },
};
exports.config =config

, When I Execute the 2nd command via CMD I'm able to debug using chromedev Tools debugger. but when I need to debug using the VS code Editor:this is present in my launch.json file:

"type": "node",
"name": "manager",
"request": "launch",
"protocol": "auto",
//  "port": 5859,
"program": "${workspaceRoot}\\node_modules\\cdem\\bin\\app",
"execArgv": ["--inspect-brk"],
"args": [
    "run wdio.debug.conf.js"
]

I keep getting the console op as: debugger attached, waiting for debugger to disconnect and the execution is not launched.

Can someone let me how to debug this app using VS Code?

Papa answered 12/6, 2018 at 16:50 Comment(2)
npx expects a module/bin as it's first argument. So, if you have jest installed as a module you can run npx jest .... I don't think npx app.js makes sense.Ribbon
Not sure if this one is still actual, WebdriverIO debugging docs were updated and there is an example VSCode config webdriver.io/docs/… Does it resolve your issue?Empedocles
L
3

https://webdriver.io/docs/debugging provides details on how to run in VS code (thank you Mike (comment)):

  1. Go to Run and Debug tab/blade (Ctrl + Shift + D)

  2. Create a launch.json file (e.g. type Node.js on environment bar) or click the cog at the top for other options

  3. .vscode/launch.json opens up or locate and open it (from project's root folder)

  4. Paste this in the configurations array, adjust according to your parameters/arguments and save the file:

     {
         "name": "run select spec",
         "type": "node",
         "request": "launch",
         // To run all spec files remove "--spec", "${file}" from below
         "args": ["wdio.conf.js", "--spec", "${file}"],
         "cwd": "${workspaceFolder}",
         "autoAttachChildProcesses": true,
         "program": "${workspaceRoot}/node_modules/@wdio/cli/bin/wdio.js",
         "console": "integratedTerminal",
         "skipFiles": [
             "${workspaceFolder}/node_modules/**/*.js",
             "${workspaceFolder}/lib/**/*.js",
             "<node_internals>/**/*.js"
         ]
     },
    
  5. Run the above by choosing this configuration (e.g. "run select spec") from the top left dropdown/select menu (or press F5 if already selected).

Lucianaluciano answered 22/11, 2021 at 18:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.