Owen M
Owen M

Reputation: 2764

VSCode debugger messing up relative paths

So I'm trying to run the VSCode debugger run my express program, but I noticed that it's messing up the relative directory paths.

When using a module like JIMP, a Node image manipulator, when I run the app from the Powershell, I need to enter the path relative to the project root (where the package.JSON is) to find the image. But when I run it from the VSCode debugger, I get an error, because it is finding the image relative to my app directory, which is a folder in my project root.

Is there a configuration I can edit to fix this?

launch.json :

{
    // Use IntelliSense to learn about possible Node.js debug 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": "node",
            "request": "launch",
            "name": "npm start",
            "program": "${workspaceRoot}/app/app.js"
        }
    ]
}

jsconfig.js :

{
    "compilerOptions": {
        "target": "es6",
        "module": "commonjs",
        "allowSyntheticDefaultImports": true
    },
    "exclude": [
        "node_modules"
    ]
}

Thanks in advance

Upvotes: 14

Views: 8282

Answers (1)

Owen M
Owen M

Reputation: 2764

Solved it:

You need to include "cwd": "${workspaceRoot}" in your launch.json

Upvotes: 18

Related Questions