Can't set Breakpoints debugging Node Typescript in VS Code
In order to debug typescript you need to generate sourcemap files. Make sure the following is in your tsconfig.json
, you should see .js.map
files generated in your build directory.
{ "compilerOptions": { "sourceMap": true }}
With gulp-typescript:
gulp-typescript
suggests that gulp-sourcemaps should be used to generate source maps.
This is the gulp task I got working creating .js.map
files that breaks on breakpoints. Found in this gulp-typescript issue
var gulp = require('gulp');var sourcemaps = require('gulp-sourcemaps');var path = require('path');var ts = require('gulp-typescript');gulp.task('compile', () => { tsProject = ts.createProject('tsconfig.json'); let tsResult = tsProject.src() .pipe(sourcemaps.init()) .pipe(tsProject()); tsResult.js .pipe(sourcemaps.write({ sourceRoot: function (file) { var sourceFile = path.join(file.cwd, file.sourceMap.file); return path.relative(path.dirname(sourceFile), file.cwd); } })) .pipe(gulp.dest('build'));});
Since updating VS Code I could no longer debug applications.
By downloading 1.23 I was able to debug again.
Please see the answer posted here:
Also here:
Visual Studio Code - Node debugger breakpoints not being hit