Skip to content

Debugging TypeScript in non-root folder can't find corresponding JavaScript #973

@AndrewFerr

Description

@AndrewFerr

After using the fix for #960, if a debug session is launched for TypeScript file that resides within a subdirectory, the debugger is unable to find its corresponding JavaScript, even when the JavaScript has unambiguous source maps & a tsconfig.json file specifies the location of the JavaScript.

Steps to reproduce:

  • Initialize a new directory with npm/yarn & a Typescript installation, and make an Eclipse project out of it.
  • Write a tsconfig.json that includes at least "sourceMap": true & "outDir": "./<someOutPath>", and optionally "rootDir: "./<someSrcPath>".
  • Write a simple *.ts file in ./<someSrcPath> and compile it with tsc (and make sure it picked up the tsconfig.json by checking that generated the *.js file is in ./<someOutPath>).
  • Place a breakpoint on your *.ts file and debug it with Debug As > Node Application.

Results:
The debug session with fail with this error dialog:

Unexpected exception
org.eclipse.lsp4j.jsonrpc.ResponseErrorException: Cannot launch program '{path}' because corresponding JavaScript cannot be found.

Workarounds:

  • Run the generated *.js file with node --inspect-brk in a terminal (or with External Tool Configurations > Program), and attach to it with Debug Configurations > Running Node.js application.
  • Move the *.ts file to the root directory of the project (and remove "rootDir" from the tsconfig.json if it was specified), the recompile & relaunch the debug session.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions