最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - VSCode debugger messing up relative paths - Stack Overflow

programmeradmin1浏览0评论

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: /?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

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

Share Improve this question edited Mar 25, 2017 at 17:51 Owen M asked Mar 25, 2017 at 16:41 Owen MOwen M 2,7643 gold badges20 silver badges39 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 18

Solved it:

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

发布评论

评论列表(0)

  1. 暂无评论