In tradition, we put launch.json and tasks.json in .vscode folder in order to make debugger works. Meanwhile, VS Code also support developer to put these 2 configurations into workspace by setting them in *.vscode-workspace. Here are the steps to reproduce:
- Create new js project by
npm initwith all default parameters. - Create new
index.jswith 1 line of code:console.log('done'); - Create new
ts-sample.code-workspacefile within the same root folder, the content should be like following:
{
"launch": {
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"skipFiles": [
"<node_internals>/**"
],
"program": "${workspaceFolder}/index.js",
"preLaunchTask": "nodeversion"
}
]
},
"tasks": {
"version": "2.0.0",
"tasks": [
{
"label": "nodeversion",
"type": "npm",
"script": "nodeversion",
}
]
},
"folders": [
{
"path": "."
}
]
}
- Open the workspace
- Open
index.jsand press F5 - Error dialog prompted our with the following error message:
Could not find the task 'nodeversion' - Open OUTPUT Panel and Error message is shown as following:
Error: The npm task detection didn't contribute a task for the following configuration:
{
"label": "nodeversion",
"type": "npm",
"script": "nodeversion"
}
The task will be ignored.
For easy demo please clone the sample project from https://github.com/mannok/WorkspaceLaunchTaskDemo
Is this a bug of VS Code or something I have missed?