使用VS代码debugging器不能将断点设置为打字稿

我的项目有以下结构

.vscode | |____launch.json dist | |____server.js | |____server.js.map node_modules src | |____server.ts gulpfile.js package.json tsconfig.json 

我的launch.json

 { "version": "0.2.0", "configurations": [ { "name": "Attach", "type": "node", "request": "attach", "port": 9229, "address": "localhost", "restart": false, "sourceMaps": true, "outFiles": ["${workspaceRoot}/dist/**/*.js"], "localRoot": "${workspaceRoot}/src/**/*.js", "remoteRoot": null, "protocol": "inspector" } ] } 

我的gulpfile.js

 const gulp = require('gulp'); const ts = require('gulp-typescript'); const nodemon = require('gulp-nodemon'); const sourcemaps = require('gulp-sourcemaps'); const JSON_FILES = ['src/*.json', 'src/**/*.json']; // pull in the project TypeScript config const tsProject = ts.createProject('tsconfig.json'); gulp.task('scripts', () => { return tsProject.src() .pipe(sourcemaps.init()) .pipe(tsProject()) .js.pipe(sourcemaps.write(".")) .pipe(gulp.dest('dist')); }); gulp.task('watch', ['scripts'], () => { return gulp.watch('src/**/*.ts', ['scripts']); }); gulp.task('assets', function () { return gulp.src(JSON_FILES) .pipe(gulp.dest('dist')); }); gulp.task('nodemon', ['scripts', 'assets', 'watch'], () => { nodemon({ script: './dist/bin/start.js', nodeArgs: ['--inspect'] }); }); gulp.task('default', ['nodemon']); 

而我的tsconfig.json

 { "compilerOptions": { "target": "es6", "module": "commonjs", "outDir": "dist" }, "include": [ "src/**/*.ts" ], "exclude": [ "node_modules" ] } 

我使用npm run startdev启动我的开发环境,它执行npm run startdev 。 因此, nodemon的默认nodemon任务运行,将我的代码编译到dist文件夹。 我能够附加debugging器,但每当我尝试设置一个断点,它是灰色的一条消息Breakpoint ignored because generated code not found (source map problem?). 我认为我的launch.json没有正确configuration。 我在这里错过了什么?