Issue with VSCode debugger causing inconsistencies with relative file paths

I'm currently facing an issue with running my Express program in VSCode debugger, as it seems to be causing problems with the relative directory paths.

For instance, when I utilize a module like JIMP, which is a Node image manipulator, the app works fine when executed from Powershell by entering the path relative to the project root (where the package.JSON is located). However, when running it through the VSCode debugger, it encounters errors because it searches for the image relative to the app directory within my project root.

Is there a configuration setting that can be modified to resolve this issue?

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

Your assistance is greatly appreciated

Answer №1

Found the solution:

To solve your issue, make sure to add "cwd": "${workspaceRoot}" to your launch.json

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

Choosing the date and time using the picker with the type of 'datetime-local'

Is there a way to ensure that the start date/time is always earlier than the end date/time when selecting them using two text-field HTML elements? <v-text-field id="setTime" outlined type="datetime-local" label="Start ...

What is the reason for the browser attempting to access files via HTTPS when the host is set as 0.0.0.0?

My application was built using create-react-app. When the app is built, it generates an HTML file along with some JS and CSS files. The HTML file typically looks like this: <!doctype html>...<script src="/static/js/main.89f33fbb.chunk.js" ...

Guidelines for callbacks and the impact on scope

I am currently diving into the world of scopes in angularjs, specifically when it involves calling callbacks on the module utilizing a directive. I have discovered three different methods to achieve the same goal and I am attempting to comprehend the advan ...

"Enhance your website with stylish Bootstrap navigation hover effects

I incorporate Bootstrap's nav component into my website design. Occasionally, when hovering over the navigation links, they display as green as intended. However, there are instances after reloading the page or returning from a link where the links d ...

Set default values for other options when an option is selected in Angular

Question: How do I use the selected sizes as an index to match and show the correct price and tsin associated with that size index? Notice: I am attempting to create a connection between sizes, prices, and tsin "Black": { "sizes": "X Small, Sma ...

If the number of list items exceeds 3, hide the additional ones and add them to the HTML using jQuery

I have a large list of items and I am interested in displaying only the first 3 items initially. When a button is clicked, I want to reveal the hidden items. Rather than cutting off words mid-way as it currently does, I prefer to hide entire words that ex ...

Ways to expand Sequelize model

Can a model be extended or inherited in order to add hooks and fields after the model has been defined? Is there a method for achieving this, similar to the following example: User = sequelize.define("user", { name: sequelize.String }); makeStateful( ...

Navigating the screen reader with the cursor位

Site Design Challenge I recently discovered that the master/detail design of my website is not very accessible. The main view features a column chart where each column represents a different month. Clicking on one of these columns reveals details in a nes ...

Display information on a table using AJAX within the current webpage

I am encountering an issue with ajax on the same page. Below is my code: $.ajax({ type: "POST", url: "test.php", dataType: 'json', data: {}, success: function (data) { ...

Python alternative for duplicating items in a list similar to the Javascript Linear

As someone new to the world of programming, I find myself engrossed in a tutorial on data structures and algorithms. However, I've hit a roadblock - the code snippets provided by the author are in JavaScript, while I'm more familiar with Python. ...

Having Trouble with Building After Fork and NPM Installation on GitHub

https://github.com/czeckd/angular-dual-listbox Discovering a Github repository that caught my attention, I decided to incorporate it into my Angular 5 application. However, after noticing certain styles and functionality that needed modification or additi ...

Trouble communicating with child component in Vue 3.0 - no event received

I have a button component that acts as a child component <template> <div class="button-container"> <el-button @click="$emit('onClick')" type="primary">{{ text }}</el-button> </div&g ...

Tips for utilizing date objects instead of date 'strings' while still obtaining the desired outcome

Below is a schema that I am working with: var MySchema = new Schema ({ event: { full: String, date: String, name: String, } }); To illustrate, here are some examples of the values: event.date = '16/02/20 ...

When employing a prop function within the useEffect return statement, you may encounter the error message: prop.function is

I'm currently working on developing a next.js app. My goal is to pass a function to a component and call it using useEffect. The following component is designed to change the props of the parent element, so I pass the function from the parent like t ...

What is causing the #reset button to trigger the Flow.reset() function when the #gameboard does not contain any child elements?

Whenever I click on the resetBtn, it triggers the Flow.reset function regardless of whether the gameboard has child elements. Am I using the hasChildNodes() method incorrectly? const resetBtn = document.querySelector('#reset'); resetBtn.addEventL ...

Incorporating numerous dropdown menus to a table filled with data retrieved from a database

I have implemented a dynamic table that adds a new row at the end when a button is clicked. One of the columns in the table contains a dropdown list, and I want this dropdown list to display values from a database. This is how I am constructing my table ...

Error: Module 'aurelia-http-client' not found during build process

I have completed the following: executed jspm install aurelia-http-client configured gulp to bundle my framework JavaScript. executed gulp bundle verified the resulting file, which now includes aurelia-http-client with the correct version number. I have ...

Aggregating quantities of various items using Redux

I'm in the process of setting up a shopping cart using Redux. Essentially, my React code retrieves product details from a database and displays them for the user. Below is a snippet of my App.js: function GetProductsHtml() { initProducts() con ...

When the function is called, it returns nothing or an empty value

Below is a script I have created function secondval_prompt(firstval) { var secondval = prompt("Please enter a value greater than the first one"); if((secondval > firstval) && (secondval != "") && (!isNaN(secondval))) { return se ...

Implementing Node.js on several domains with the help of express.vhosts()

I'm facing a challenge with my nodejs setup. I am in the process of developing a node server that will support multiple instances of app.js running simultaneously on the same system using express.vhost(). However, I seem to have hit a roadblock. The ...