Search code examples
windowsmacostypescriptvisual-studio-codeplatform

Multiple platforms vscode launch.json config slashes


I'm working on a typescript project, one of the developers is on windows and the other on Mac OS, the problem i have at the moment is that the slashes for directories doesn't work(Windows \ and Mac OS /). In my launch.json file in the .vscode directory, i have a config like this:

{
    "version": "0.2.0",
    "configurations": [
        {
            "program": "${workspaceRoot}/src/main.ts",
            "cwd": "${workspaceRoot}/tests/reference"
        }
    ]
}

So i tried to do:

{
    "version": "0.2.0",
    "osx" : {
        "configurations": [
            {
                "name": "Launch",
                "type": "node",
                "request": "launch",
                "program": "${workspaceRoot}/src/main.ts",
                "cwd": "${workspaceRoot}/tests/reference"
            }
        ]
    },
    "windows" : {
        "configurations": [
            {
                "name": "Launch",
                "type": "node",
                "request": "launch",
                "program": "${workspaceRoot}\\src\\main.ts",
                "cwd": "${workspaceRoot}\\tests\\reference"
            }
        ]
    }
}

But the compiler complains that the configuration doesn't exist, so i guess i can't do that.


Solution

  • So in the end, it turns out you can use a single forward slash and this will work for both Windows, OSX and Linux.

    {
        "version": "0.2.0",
        "configurations": [
            {
                "program": "${workspaceRoot}/src/main.ts",
                "cwd": "${workspaceRoot}/tests/reference"
            }
        ]
    }
    

    Previously i had been trying to make the \ work but obviously wouldn't.