The VS Code Debugger can be tricky to work with until you set it up. There are a lot of options but the following code will allow you to run individual files:
- Open the Run and Debug panel in VS Code;
- Create a
launch.json
file if one doesn't already exist; - Add a "Run Current File" configuration by adding it to your
launch.json
file:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
// Other existing configurations...
},
// Add this configuration to your launch.json file
{
"name": "Run Current File",
"program": "${file}",
"request": "launch",
"skipFiles": [
"<node_internals>/**"
],
"type": "node"
}
]
}
- Try running
hello.js
(included in this gist) in the debugger to confirm it works;