Я пытаюсь получить отладку в VS Code, работающем с сервером Experss (REST API).Я перепробовал несколько конфигураций launch.json, прочитал документацию и несколько постов на Stankoverflow, включая VS Code: помощь в отладке angular 2 с помощью express , но безуспешно.Вот структура и конфигурация моего проекта
|-.vscode
|-config
|-db
|-dist
|-routes
|-server
|
|-index.js // entry point
Я использую файлы JavaScript с es6 / 7, скомпилированные с Babel 7. Исходные карты генерируются Babel и располагаются рядом со связанным файлом (то есть тем же каталогом).).
Babel вызывается из сценария npm
"transcompile": "babel . -d dist --ignore node_modules --source-maps",
.babelrc
{
"presets": ["@babel/preset-env"],
"plugins": [
"@babel/plugin-transform-runtime",
],
"sourceMaps": "both",
"highlightCode": true,
}
Моя конфигурация
launch.json
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "server",
"program": "${workspaceFolder}/dist/server/index.js",
// "program": "${workspaceFolder}/server/index.js",
"smartStep": true,
"outFiles": [
"${workspaceRoot}/dist/**/*.js",
"${workspaceRoot}/dist/*.js"
],
"env": {
"NODE_ENV": "devLocal"
},
"protocol": "inspector",
"skipFiles": [
"${workspaceFolder}/dist/server/node_modules/**/*.js",
"<node_internals>/**/*.js",
]
},
]
}
Outcome of running debugger
> If "program" points to original source: Debugger starts and then just stops. No sign that the app ran and no errors.
> If "program" points to /dist: Debugger & App starts. Doesn't hit brakepoint from initial load. Does hit breakpoint when calling API from browser. However, stepping doesn't follow the expected course (i.e., stepping through the code I wrote). It goes into files in /node_modules and never turns to my code. This is true even using step-over (shift+F11).
In addition to overall what needs to change in the configuration to get things working, I'm also wondering the following
- Do I need "program"
- Should "program" point to the original source ("${workspaceFolder}/server/index.js") or to /dist ("${workspaceFolder}/dist/server/index.js")
- Do I need "skipFiles" since "smartStep" is set?
- ... and should "skipFiles" point to the original source or /dist