【发布时间】:2016-02-05 01:03:12
【问题描述】:
我正在尝试使用 Visual Studio Code 调试以下打字稿代码:
class Student {
fullname : string;
constructor(public firstname, public middleinitial, public lastname) {
this.fullname = firstname + " " + middleinitial + " " + lastname;
}
}
interface Person {
firstname: string;
lastname: string;
}
function greeter(person : Person) {
return "Hello, " + person.firstname + " " + person.lastname;
}
var user = new Student("Jane", "M.", "User");
console.log(greeter(user));
这是我的 launch.json 配置文件:
{
"version": "0.1.0",
// List of configurations. Add new configurations or edit existing ones.
"configurations": [
{
// Name of configuration; appears in the launch configuration drop down menu.
"name": "TypeScriptDebugTest",
// Type of configuration.
"type": "node",
// Workspace relative or absolute path to the program.
"program": "./HelloWorld.ts",
// Automatically stop program after launch.
"stopOnEntry": false,
// 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,
// Optional arguments passed to the runtime executable.
"runtimeArgs": ["--nolazy"],
// Environment variables passed to the program.
"env": {
"NODE_ENV": "development"
},
// Use JavaScript source maps (if they exist).
"sourceMaps": true,
// If JavaScript source maps are enabled, the generated code is expected in this directory.
"outDir": "./built"
}
]
}
javascript 编译文件位于根目录下的 build 文件夹中。当我尝试调试时,同样的错误不断出现:“无法连接到运行时进程(5000 毫秒后超时)”
注意:我想调试的是 .ts 文件,而不是编译后的 javascript。
有谁知道如何解决这个问题?
谢谢!
【问题讨论】:
-
这是节点 4.x 的吗?
-
是的@BenjaminPasero 我正在使用节点 4.x
标签: debugging typescript visual-studio-code