【发布时间】:2015-09-19 01:53:49
【问题描述】:
使用 0.3 版的 Visual Studio 代码,我不确定如何启用源映射和调试 ts 文件
我收到以下错误can't launch program '/Projects/app-server/server.ts'; enabling source maps might help
如何启用源映射和打字稿调试。 Sourcemap 在我的
中设置为 truetsconfig.json
{
"compilerOptions": {
"target": "ES5",
"module": "commonjs",
"sourceMap": true
}
}
launch.json
{
"version": "0.1.0",
// List of configurations. Add new configurations or edit existing ones.
// ONLY "node" and "mono" are supported, change "type" to switch.
"configurations": [
{
// Name of configuration; appears in the launch configuration drop down menu.
"name": "Launch server.ts",
// Type of configuration. Possible values: "node", "mono".
"type": "node",
// Workspace relative or absolute path to the program.
"program": "server.ts",
// Automatically stop program after launch.
"stopOnEntry": true,
// Command line arguments passed to the program.
"args": [],
// Workspace relative or absolute path to the working directory of the program being debugged. Default is the current workspace.
"cwd": ".",
// Workspace relative or absolute path to the runtime executable to be used. Default is the runtime executable on the PATH.
"runtimeExecutable": null,
// Environment variables passed to the program.
"env": { }
},
{
"name": "Attach",
"type": "node",
// TCP/IP address. Default is "localhost".
"address": "localhost",
// Port to attach to.
"port": 5858
}
]
}
【问题讨论】:
-
你有
"program": "server.ts",但你应该执行输出的js文件,并且在那个js文件中将是指向ts文件的必要源映射信息 -
最初使用源映射尝试过,但它不会在 ts 文件中的断点处停止
-
我收到同样的错误信息。升级到TypeScript 0.5版本后没有变化。
-
做@Brocco 所说的对我有用。确保在 tsconfig.json 文件中包含
"sourceMap": true。
标签: typescript visual-studio-code