VSCode调试器弄乱了相对路径

时间:2017-03-25 16:42:00

标签: javascript debugging npm visual-studio-code

所以我正在尝试运行VSCode调试器运行我的快速程序,但我注意到它搞乱了相关的目录路径。

当使用像JIMP这样的节点图像操纵器这样的模块时,当我从Powershell运行应用程序时,我需要输入相对于项目根目录的路径(package.JSON所在的位置)到找到图像。但是当我从VSCode调试器运行它时,我收到一个错误,因为它找到了相对于我的app目录的图像,这是我项目根目录中的一个文件夹。

我可以编辑一个配置来修复此问题吗?

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

提前致谢

1 个答案:

答案 0 :(得分:5)

解决了它:

您需要在"cwd": "${workspaceRoot}"

中加入launch.json
相关问题