1

I'm developing a node module and an example application along with it. I'm trying to add debugging breakpoints to one of the source files in the module but I can not get VSC to recognize it. Using the latest versions of Typescript and VSC.

EDIT: This is supposed to be a node application, no browser to worry about.

EDIT2: Here is repo with the issue repo with problem. Here is my current setup

├── dist
│   ├── index.d.ts
│   ├── index.js
│   ├── index.js.map
│   ├── main.d.ts
│   ├── main.js
│   ├── main.js.map
├── examples
│   ├── index.js
│   └── package.json
├── gulpfile.js
├── package.json
├── src
│   ├── index.ts
│   ├── main.ts
├── tsconfig.json
├── tslint.json

I'm developing the example in examples/index.js and I'm setting the breakpoints in src/main.ts

this is my VSC launch.json configuration

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Launch TypeScript",
      "type": "node",
      "request": "launch",
      "program": "${workspaceRoot}/examples/index.js",
      "sourceMaps": true,
      "outDir": "${workspaceRoot}/src",
      "args": [
        "--nolazy"
      ]
    }
  ]
}

my tsconfig.json

{
    "compilerOptions": {
      "target": "es2015",
      "module": "commonjs",
      "sourceMap": true,
      "outDir": "dist",
      "declaration": true,
      "rootDir": "src"
    },
    "exclude": [
      "node_modules",
      "examples",
      "dist"
    ]
}

my gulp task

gulp.task('default', function () {
  var tsResult = tsProject.src('tsconfig.json')
    .pipe(sourcemaps.init())
    .pipe(ts(tsProject));

  return merge([
        tsResult.dts.pipe(gulp.dest('dist')),
        tsResult.js
        .pipe(sourcemaps.write('.', {includeContent: false, sourceRoot: 'src'}))
        .pipe(gulp.dest('dist'))
    ]);
});

how the sourcemaps are coming put

{"version":3,"sources":["main.ts"],"names":[],"mappings":";CAAC,...CAAC","file":"main.js","sourceRoot":"src"}
3
  • Typescript files never get executed, they get converted to Javascript and that is what is ran. I'm not sure if you can put code breaks in Javascript files in VS, but you can in developer tools. Commented Jun 14, 2016 at 17:19
  • I should also clarify that these are node applications Commented Jun 14, 2016 at 17:21
  • Oh, well then I have no clue, sorry. Commented Jun 14, 2016 at 17:23

2 Answers 2

1

Visual Studio Code is using "program" to reference the filename "index.js" in the corresponding "outDir". In your case it's looking for "dist/index.js".

Having an alternate entry file is causing the confusion. To avoid the name collision, "examples/index.js" needs to be a unique filename(exampleApp.js?) that doesn't exist in "dist".

Sign up to request clarification or add additional context in comments.

Comments

0

You probably need to change "outDir" to "${workspaceRoot}/dist". The Node debugger uses that flag to find your generated scripts.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.