express-mongoose-es6-rest-api icon indicating copy to clipboard operation
express-mongoose-es6-rest-api copied to clipboard

question: debug in vscode

Open laokele opened this issue 8 years ago • 6 comments

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.

laokele avatar Apr 13 '17 17:04 laokele

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.

richjava avatar May 19 '17 22:05 richjava

@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" ]
    }

okonon avatar May 20 '17 03:05 okonon

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"
            ]
        }
    ]

richjava avatar May 21 '17 03:05 richjava

Thanks!!! @richjava @okonon This works great!

laokele avatar May 22 '17 00:05 laokele

@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..

arihantdaga avatar Nov 21 '17 06:11 arihantdaga

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"
        ]
    }

bijeshp avatar Dec 13 '17 09:12 bijeshp