Guide on troubleshooting Node TypeScript in Visual Studio Code when the JavaScript source is stored in a separate directory

When using Visual Studio Code, I am able to debug and step through the TypeScript source code of Main.ts. This is possible as long as the JavaScript and map files are located in the same folder as the TypeScript source.

This setup works well in this structure:

debugDemo\
     .vscode
              launch.json        
     TypeScript\
               Main.ts
               Main.js
               Main.js.map

However, I prefer to have the JavaScript files in a separate folder called JavaScript rather than keeping them in the TypeScript folder. To achieve this, I tried configuring the launch.json file with an outFiles attribute to specify the location of the JavaScript files.

Unfortunately, I encountered an error with this arrangement:

debugDemo\
     .vscode
              launch.json        
     TypeScript\
               Main.ts
    JavaScript\        
               Main.js
               Main.js.map

The error message always states - "Cannot launch program 'c:\debugDemo\TypeScript\Main.ts'; setting the 'outFiles' attribute might help"

https://i.stack.imgur.com/xfGMo.png I need help figuring out how to configure Visual Studio Code to locate the JavaScript files in the JavaScript folder. I have experimented with different glob patterns for outFiles, but it hasn't resolved the issue.

Main.ts I simplified the code to just one line for easier troubleshooting purposes.

  console.log("debug"); 

The map files were generated using:

tsc --sourcemap TypeScript/Main.ts

which results in - TypeScript\Main.js , TypeScript\Main.js.map

launch.json

   {
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Debug Test",
            "program": "${workspaceRoot}/TypeScript/Main.ts",
            "cwd": "${workspaceRoot}",
            "outFiles": ["${workspaceRoot}/JavaScript/**/*.js"],
            "sourceMaps": true
        }
    ]
}
  • TypeScript version: 2.1.4
  • Node version: 6.9.4
  • Visual Studio Code version: 1.14.2

Answer №1

When running the command

tsc --sourcemap TypeScript/Main.ts
, the output files are not placed in the JavaScript folder as expected. To correct this, you need to include the outDir parameter and specify the destination folder for the compiled JavaScript files:

tsc --sourcemap --outDir "JavaScript"  TypeScript/Main.ts

For more information on available options, refer to the TypeScript compiler options.

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

Struggling to establish a connection between Node.js and AWS DocumentDB with Mongoose

I am currently working on my node.js code where I am attempting to establish a connection with AWS document db using mongoose. However, I am encountering the following error: const URL = "mongodb://school:SJDJDJDJDD@dev-docdb-2022-09-02-05-55-49.cqsss ...

Troubleshooting connection timeouts between node.js and amqp

In my project, I am utilizing RabbitMQ through the AMQP module in Node.js with 2 producers and 2 consumers. Here is the code snippet for establishing connections for the consumers: function init_consumers( ) { console.log( 'mq: consumers connect ...

Incorporating a static image file into a Material UI cardMedia component within a Next.js project

I am struggling to insert a static image into Material UI CardMedia component. I have tried the following code: const useStyles = makeStyles((theme) => ({ media: { height: 0, paddingTop: "56.25%", // 16:9 }, })); <CardMed ...

Leveraging Konva in a Node.js server environment without the need for Konva-Node

We are a group of 5 developers collaborating on a project involving video rendering. This project consists of two main components. Creating a live video preview in the browser using angular + konva. Developing a node.js (node 14) serverless implementation ...

Error connecting SQL Server with NodeJS

Currently, I am facing an issue while connecting SQL Server using NodeJS. Initially, my code looked like this: const poolA = new sql.ConnectionPool(config, err => { poolA.request() .query("select * from AnyTable", function(err, res ...

Having trouble retrieving the value from the input field with Angular.js

I am having trouble retrieving the value from an input field using Angular.js. Below is the code explanation. Here is my controller code: $scope.shipping=0; $scope.addProductInfoData=function(billdata){ console.log('valid',$scope.shippi ...

I encountered an issue in reactjs where I received the error message: TypeError: this.state.coords.map is not functioning properly

Here is the code snippet I wrote: import React, { Component } from 'react'; class LocationApp extends Component { constructor(props){ super(props) this.state = { coords:[], error:[], } } ...

Editable Table Component in React

I've developed a React table as shown below: const CustomTable = ({content}) => { return ( <table className="table table-bordered"> <thead> <tr> <th>Quantity</ ...

Is there a way to prevent ng-template-loader from scanning image src's?

Currently, I am beginning to incorporate webpack into my development workflow for an angular project. To create my templateCache, I have had to include the ng-template-loader. Below is a snippet of my webpack configuration: { test: /\.html$/, loa ...

What is the best way to simulate a library in jest?

Currently, I am attempting to simulate the file-type library within a jest test scenario. Within my javascript document, this particular library is utilized in the subsequent manner: import * as fileType from 'file-type'; .... const uploadedFil ...

Modifying an HTML list item to become 'active' in a navigation bar

One way I've been implementing my navbar on each page is by using the following code at the bottom of the page within script tags: $("#navbar-partial").load("navbar.html). The code for the navbar list looks like this: <ul id="main-nav" class="nav ...

Retrieve the property value from a nested object using a key that contains spaces

Presenting my object: let obj = { innerObj: { "Key with spaces": "Value you seek" } } Upon receiving, I am unaware of the content within obj. I possess a string variable holding the key to access the value. It appears as follows: let ke ...

Using Angular promises and the $http service

ng.module('app') .service('CardService', ['$http', CardService]) function CardService($http) { this.$http = $http; var self = this; $http.get('http://localhost:3000/db').success(function(data) { ...

The npm-default error is currently inaccessible

After updating the npm in openSUSE 42.2 Leap, I encountered an error: npm-default is unavailable. Upon investigation within npm: #!/bin/sh PROG=$(basename $0) PROG_VERSION=${NODE_VERSION:--default} if [ ! -x /usr/bin/${PROG}${PROG_VERSION} ]; then ...

Turn off Chrome 69's autofill functionality

I've recently encountered an issue with Chrome's password autofill feature that has been troubling me for a few days now. This problem began when I was using Chrome version 69. After much trial and error, I found a solution by removing the id an ...

Extract specific data points from external API responses on a webpage crafted in HTML

I require assistance on how to extract individual values from an HTML page. I received a response from the PAYU payment gateway team in HTML format, but I need to retrieve specific attribute values related to the transaction details. Below is the response ...

What is the best way to verify if an object is an instance of a particular class using Jasmine testing?

In the process of developing an Angular application, I am currently working on testing a component using this guide. My goal is to ensure that when my ngOnInit() method is called, it correctly initializes my foos property with an array of Foo objects based ...

Error: Unable to replay message

const { Client, Intents } = require('discord.js'); const { token } = require('./config.json'); const client = new Client( { intents: [ Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILD ...

Exploring the elements within the ContentChildren directive in Angular

Presenting my component: import { Component, OnInit, ContentChildren, QueryList } from '@angular/core'; import { IconBoxComponent } from '../icon-box/icon-box.component'; @Component({ selector: 'app-three-icon-box', temp ...

Guide on transferring datetime information from a popup dialog to an MVC controller

My goal is to create a button that, when clicked, opens a dialog allowing the selection of start and end dates. Upon clicking ok/submit, the selected datetime should be passed to a controller [HttpPost] action method. Here's what I have attempted so f ...