VSCode 调试器弄乱了相对路径 [英] VSCode debugger messing up relative paths

查看:43
本文介绍了VSCode 调试器弄乱了相对路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我试图运行 VSCode 调试器运行我的 express 程序,但我注意到它弄乱了相对目录路径.

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.

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

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

提前致谢

推荐答案

已解决:

您需要在 launch.json

这篇关于VSCode 调试器弄乱了相对路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆