Configuring slashes in launch.json across various platforms with vscode

In the midst of working on a project in TypeScript, I encountered a dilemma involving two developers using different operating systems - one on Windows and the other on Mac OS. The issue at hand is the conflicting directory slashes (\ for Windows and / for Mac OS). Within my launch.json file located in the .vscode directory, the configuration appears as follows:


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

To tackle this problem, I attempted the following approach:


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

However, the compiler raised an error stating that the configuration was non-existent, leading me to conclude that my initial attempt was not viable.

Answer №1

It's interesting to note that using just a single forward slash will actually work across all operating systems, including Windows, OSX, and Linux.

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

I had previously attempted to use the backslash (\) character, which was clearly not the correct approach.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Error: Unable to iterate over data.data due to its type

I am attempting to fetch images from the woocommerce API and here is the code I am using: this.config.getWithUrl(this.config.url + '/api/appsettings/get_all_banners/?insecure=cool') .then((data: any) => { this.banners = data.data; consol ...

Persist changes to array even after refreshing the page

Currently, I am utilizing Angular 2 (Typescript) to code my webpage, which features various forms with inputs. Upon submitting these forms, they each trigger a function that adds a new instance of an object based on the inputs to an array. This array is th ...

Angular Error: Attempting to access property 'then' of undefined object causes TypeError

I am struggling with implementing JHipster Auth-guard. I am facing an issue where canActivate is not triggered for a user without permission for a specific route. I have carefully examined my code, but the console shows that .then() is undefined at the sp ...

Trying to enter the function, but it exits without executing

I'm facing an issue with my function that involves making multiple calls to an observer. I need the function to wait until all the calls are complete before returning. I attempted putting the return statement inside the subscribe method, but it result ...

What is the proper way to format parameters for a get request?

I am attempting to achieve the following: export interface ApiCallOptions { abc: string, xyz: number } makeRequest (options: ApiCallOptions) { return this.http.get('/some/path/to/endpoint', { params: options }); } However, I encounter an e ...

What steps can be taken to initiate Nx Release on the apps/* when modifications are made to the connected libs/* modules?

Trying out the nx release command but struggling to get it to release an app when there are changes to a dependent module. Examining the graph below, you can see that I have 3 apps, with 2 depending on the shared-ui module. https://i.sstatic.net/QYDBlRnZ.p ...

Using Typescript for-loop to extract information from a JSON array

I'm currently developing a project in Angular 8 that involves utilizing an API with a JSON Array. Here is a snippet of the data: "success":true, "data":{ "summary":{ "total":606, "confirmedCasesIndian":563, "con ...

I'm looking for a way to merge the functionalities of tsc build watch and nodemon into a single Node.js

Currently, I have two scripts in my code: "scripts": { "build": "tsc -p . -w", "watchjs": "nodemon dist/index.js" } I need to run these two scripts simultaneously with one command so that the build ...

Refreshing a variable during component initialization

In the Event 1 component, there is a variable that holds a string from another variable in the data.service. I want to update the data.service string to 'Event 2' when the Event 2 component loads. I have attempted to implement the following code ...

redux-saga 'call' effect fails to properly type saga parameters

My saga is defined as follows: type GenericFunction = (...args: any[]) => any; interface IFetchSaga<T extends GenericFunction> { saga: T, args: Parameters<T> } function* triggerChange<T extends GenericFunction>(fetchSaga: IFetchS ...

Steps for ensuring a prop is required in TypeScript React based on a condition

interface IPerson { name: string; gender: string; vaccinated: 'yes'|'no'; vaccineName?: string } In this interface, the property vaccineName is optional while other properties are required. If the property vaccinated is yes ...

Automatically convert TypeScript packages from another workspace in Turborepo with transpilation

I have set up a Turborepo-based monorepo with my primary TypeScript application named @myscope/tsapp. This application utilizes another TypeScript package within the same repository called @myscope/tspackage. For reference, you can view the example reposit ...

Having an issue with displaying the country name and country code in a table using the Angular7 custom pipe

country code: "ab", "aa", "fr", ... I need to create a custom pipe that will convert a countryCode into a countryName, such as: "ab" → "Abkhazian", "ch" → "Chinese", "fr" ...

Utilizing ES6 Map type in TypeScript for Angular 2 Response Data Transfer Object Definition

Is it possible to utilize the es6 Map type in an HTTP Response DTO? Let's consider an Angular 2 request: public loadFoos(): Observable<FoosWrapper> { return this.http.get("/api/foo") .map(res => res.json()); } Now, take a loo ...

TS does not recognize the term "Response"

After I launch my function, why does the console throw this error: ReferenceError: Response is not defined Here's my code snippet: @Get('/download/:fileId') @Header('Content-Type', 'application/vnd.openxmlformats-offi ...

I am curious to know which vscode setting controls the unusual indentation with an extra space and newline that occurs when a closing bracket is on the same line

Lately, I've noticed a strange issue while using VScode - there seems to be an unexpected extra space, particularly since I updated to the latest version. This peculiarity occurs when editing Python code and involves a scenario where there is a closi ...

Managing two select fields in a dynamic Angular form - best practices

On my screen, I am dynamically creating elements using a reactive form. Specifically, I am creating cards with two selection fields each: https://i.sstatic.net/WUvQH.png Situation: When I add a card and choose a layout, the options for that specific layo ...

Handling Promises in Angular 1 App using Typescript ES6/2015

Currently, I am working on an Angular 1.5 application that utilizes Typescript. My main concern is finding the most efficient way to handle ng.IPromise compared to Promise (ES6 promise). Personally, I would prefer to solely deal with the ES6 Promise type. ...

Verifying TypeScript errors before each commit in a Vue application

We have set up a git hook in our app using Husky for pre-commit actions. Whenever someone commits code, it triggers the pre-commit code - #!/bin/sh . "$(dirname "$0")/_/husky.sh" export NVM_DIR="$HOME/.nvm" [ -s "$NVM_ ...

Trying out Angular2 service using a fabricated backend

Just a heads up: I know Angular2 is still in alpha and undergoing frequent changes. I am currently working with Angular2 and facing an issue with testing an injectable service that has a dependency on http. I want to test this service using a mock backend ...