express-mongoose-es6-rest-api
express-mongoose-es6-rest-api copied to clipboard
question: debug in vscode
hi guys,
I was wondering if anyone has used vscode to debug this package? can you share the settings? I tried bunch of different ways, but can't get it working.....
thanks in advance.
I'd also like to know the answer to this please. I tried adding Babel but it didn't work. There are plenty of suggestions on StackOverflow with mixed results and I couldn't see anything specific to Yarn.
@laokele @richjava try this:
{
"name": "Launch",
"type": "node2",
"request": "launch",
"program": "${workspaceRoot}/index.js",
"stopOnEntry": false,
"args": [],
"cwd": "${workspaceRoot}",
"preLaunchTask": null,
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/babel-node",
"runtimeArgs": [
"--nolazy"
],
"env": {
"NODE_ENV": "dev"
},
"console": "internalConsole",
"sourceMaps": true,
"outFiles": [ "${workspaceRoot}/dist/**/*.js" ]
}
Yes, thank you @okonon
I made a few adjustments to the code you provided and now it works! :+1:
I changed
"outFiles": [ "${workspaceRoot}/dist/**/*.js" ]
to
"outFiles": [ "${workspaceRoot}/dist/server/**/*.js" ]
And because I am on Windows, I changed ${workspaceRoot}/node_modules/.bin/babel-node
to ${workspaceRoot}/node_modules/.bin/babel-node.cmd
So my configurations section is:
"configurations": [
{
"name": "Launch",
"type": "node2",
"program": "${workspaceRoot}/index.js",
"stopOnEntry": false,
"request": "launch",
"diagnosticLogging": true,
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/babel-node.cmd",
"runtimeArgs": [
"--nolazy"
],
"env": {
"NODE_ENV": "dev"
},
"console": "internalConsole",
"sourceMaps": true,
"webRoot": "${workspaceRoot}",
"sourceMapPathOverrides": {
"webpack:///./*": "${workspaceRoot}/*"
},
"outFiles": [
"${workspaceRoot}/dist/server/**/*.js"
]
}
]
Thanks!!! @richjava @okonon This works great!
@richjava Thanks for sharing this config.. I tried the same, but it's not working all the time.. one thing - i had to remove "sourceMapPathOverrides" and "diagnosticLogging" as it throws error in launch.json (these paramters are not allowed). So after running the code is not stopping on the break points..
I am getting the following error, break points are not working
Error processing "setBreakpoints": TypeError: Cannot read property 'mappedPath' of undefined
at EagerSourceMapTransformer.setBreakpoints (/Users/bijesh/Documents/Install/Visual Studio Code.app/Contents/Resources/app/extensions/ms-vscode.node-debug2/node_modules/vscode-chrome-debug-core/out/src/transformers/baseSourceMapTransformer.js:63:23)
at validateBreakpointsPath.then (/Users/bijesh/Documents/Install/Visual Studio Code.app/Contents/Resources/app/extensions/ms-vscode.node-debug2/node_modules/vscode-chrome-debug-core/out/src/chrome/chromeDebugAdapter.js:827:40)
at <anonymous>
My launch JSON
{
"name": "Launch-debug",
"type": "node2",
"program": "${workspaceRoot}/index.js",
"stopOnEntry": false,
"request": "launch",
"diagnosticLogging": true,
"preLaunchTask": null,
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/babel-node",
"runtimeArgs": [
"--nolazy"
],
"env": {
"NODE_ENV": "dev"
},
"console": "internalConsole",
"sourceMaps": true,
"webRoot": "${workspaceRoot}",
"sourceMapPathOverrides": {
"webpack:///./*": "${workspaceRoot}/*"
},
"outFiles": [
"${workspaceRoot}/dist/server/**/*.js"
]
}