I have a standalone piece of JS code that makes an HTTP request and does some work on it. Now, normally I’d debug such scripts by running them in repl.it and then console.log
ing the data. However, VS Code has a neat side panel of “Variables”, “Watch”, “Call stack” that I wish to make good use of.
I used the “Debugger for Chrome” extension from the VS Marketplace. However, every time I hit F5, the Chrome browser opens and attempts to connect to a localhost, which my JS code doesn’t need. This is my launch.json
file (generated on default):
{
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "attach",
"name": "Attach to Chrome",
"port": 9222,
"webRoot": "/FolderName"
}
]
}
What I expect to happen is that my JS code should run inside VS Code, and the call stack and variables of my code should be displayed in the left sidebar.
So, how to achieve this task?
Tags: debugging, file, java, javascript