我到处寻找,我仍然在VS Code中调试TypeScript.我已经读过这个帖子但是我仍然无法点击放在TypeScript文件中的断点,点击.js文件中的断点一切正常.
所以这里是我设置的最简单的"hello world"项目.
app.ts:
var message: string = "Hello World";
console.log(message);
Run Code Online (Sandbox Code Playgroud)tsconfig.json
{
"compilerOptions": {
"target": "es5",
"sourceMap": true
}
}
Run Code Online (Sandbox Code Playgroud)launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "node",
"request": "launch",
"program": "${workspaceRoot}/app.js",
"stopOnEntry": false,
"args": [],
"cwd": "${workspaceRoot}",
"preLaunchTask": null,
"runtimeExecutable": null,
"runtimeArgs": [
"--nolazy"
],
"env": {
"NODE_ENV": "development"
},
"externalConsole": false,
"sourceMaps": true,
"outDir": null
}
]
}
Run Code Online (Sandbox Code Playgroud)我通过运行tsc --sourcemap app.ts命令生成了js.map文件.
在所有这些步骤之后,当我console.log(message);在行上设置断点并从"调试"选项卡启动程序(F5)时,断点显示为"断点被忽略,因为找不到生成的代码(源映射问题?)".我附上了我观察的截图:
我错过了什么?
编辑:
嗨,我仍然坚持这个.我设法做了一个打破断点的示例项目但是在我尝试将该项目复制到我的硬盘驱动器上的不同位置后,断点再次变为灰色并且没有被击中.我在这个测试项目中做的不同之处是通过编译TypeScript文件来使用内联源图tsc app.ts …
使用Visual Studio代码的0.3版本,我不知道如何启用源映射和调试ts文件
我收到以下错误 can't launch program '/Projects/app-server/server.ts'; enabling source maps might help
如何启用源映射和打字稿调试.在我的中,Sourcemap设置为true
tsconfig.json
{
"compilerOptions": {
"target": "ES5",
"module": "commonjs",
"sourceMap": true
}
}
Run Code Online (Sandbox Code Playgroud)
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",
// …Run Code Online (Sandbox Code Playgroud)