Skip to content Skip to sidebar Skip to footer

How To Debug Javascript In Nodejs On Windows When I'm Not The Caller Of Node.exe

I'm trying to debug nodejs script (on Windows). I found that I can stop execution / set a breakpoint withing the script by using the 'debugger;' statement. However this seems to wo

Solution 1:

If you have the typical windows workspace such as Node, git and VSCode,
you can do it in these simple steps:

  1. In VSCode, open launch.json configuration or create new by clicking on the wheel

enter image description here

  1. The node will listen on port 9229 by default, so add this configuration:
{
  "type": "node",
  "request": "attach",
  "name": "Attach to 9229",
  "port": 9229
},
  1. Open Task Manager and locate the PID of your node process
    I could identify my by the "build" folder where the index.js is. enter image description here
  2. open another cmd or git-bash and run this command,
    where 21392 is the PID of your process.
node -e "process._debugProcess(21392)"
  1. you should see thisDebugger listening on ws:9229
  2. Start debugging from VSCode Attach to 9229
    enter image description here

Everything should be ready now.


Post a Comment for "How To Debug Javascript In Nodejs On Windows When I'm Not The Caller Of Node.exe"