I added a config start:debug
manually but then again VS Code shows another one as well. Both executes the application but when I run mine it does not show all the app console outputs in terminal e.g. errors, logs, etc. but when I run VS Code's one then everything works perfectly and I prefer to the use that config across our team.
Problem is I cant checkin the config so in another machine it does not show up as expected. How does VS Code get that config and execute it? If I can replicate that in my config then I can check it in my repo for others to use.
Here are the steps to solve your mystery: by following along, you'll both discover the task configuration settings for the elusive option, and discover how it was added to your list:
Create an empty folder (I named mine so-70196209
after this question ID), and open it in a new VS Code workspace.
Create a package.json
file in the folder. Make sure it has a start:debug
script entry like this:
package.json
:
{
"name": "so-70196209",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start:debug": "echo \"Success\"",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "MIT"
}
In the VS Code menu, select "Run" > "Add Configuration..."
In the list that appears, select "Node.js":
A file at .vscode/launch.json
will be created with a default task like this:
.vscode/launch.json
:
{
// 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": [
{
"type": "pwa-node",
"request": "launch",
"name": "Launch Program",
"skipFiles": [
"<node_internals>/**"
],
"program": "${file}"
}
]
}
You can delete this default task later if you don't want to keep it, but just leave it for now and follow along to the end.
Select the "Run and Debug" icon in the Activity Bar.
In the "Run and Debug" Side Bar, select the dropdown menu and choose "Node.js...":
In the list that appears, find the entry with the text "Run Script: start:debug". Find the gear icon on the right, and select the gear.
If you hover over the gear, a tooltip will appear with the text "Edit Debug Configuration in launch.json"
This will add a new entry to .vscode/launch.json
, and this entry is the one that you've been searching for. (The reason why it wasn't in your launch config, but was in your dropdown list, is because you previously clicked the entry line at some point, but not the gear. I don't know why this adds it to the dropdown and not the config, but that's how it works right now.)
The config file now looks like this:
.vscode/launch.json
:
{
"version": "0.2.0",
"configurations": [
{
"type": "pwa-node",
"request": "launch",
"name": "Launch Program",
"skipFiles": [
"<node_internals>/**"
],
"program": "${file}"
},
{
"type": "node-terminal",
"name": "Run Script: start:debug",
"request": "launch",
"command": "npm run start:debug",
"cwd": "${workspaceFolder}"
}
]
}
The "Run and Debug" dropdown menu now has the entry you want:
Problem solved! 🥳
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With