在VS Code中configurationtypescript debug的launch.json

这是VS Code的launch.jsonconfiguration文件。

{ "version": "0.2.0", "configurations": [{ "type": "node", "request": "launch", "name": "Launch Program", "program": "${workspaceRoot}/src/server/server.ts", "cwd": "${workspaceRoot}", "outDir": "${workspaceRoot}/build/server", "sourceMaps": true, "stopOnEntry": false, "smartStep": true, "runtimeArgs": ["--nolazy"] }, { "type": "node", "request": "attach", "name": "Attach to Process", "port": 5858, "outFiles": [], "sourceMaps": true }] } 

我不知道为什么我只能在server.ts文件上放置断点,即使代码是用sourcemaps编译的。

我使用gulp-typescript编译代码如下

 var tsProject = p.typescript.createProject(cfg.tsconfig); return gulp.src(cfg.src) .pipe(p.plumber({ errorHandler: p.notify.onError('Typescript SERVER error: <%= error.message %>') })) .pipe(p.sourcemaps.init({ loadMaps: true })) .pipe(tsProject()) .pipe(p.sourcemaps.write('./')) .pipe(gulp.dest(cfg.dest)) .pipe(p.notify({ title: 'Typescript SERVER', message: 'Server compiled!', onLast: true })); 

这是我的tsconfig.json

 { "compilerOptions": { "target": "ES5", "module": "commonjs", "moduleResolution": "node", "noEmitOnError": true, "noImplicitAny": false, "experimentalDecorators": true, "emitDecoratorMetadata": true, "sourceMap": true, "noLib": false, "outDir": "./../../build", "rootDir": "./../" }, "exclude": [ "./../client" ] }