tnk*_*nkh 12 visual-studio typescript
您好,我正在按照本教程
https://code.visualstudio.com/docs/typescript/typescript-tutorial
来调试打字稿,但我遇到了如屏幕截图所示的错误。如果我仍然选择调试,调试器可以工作,但我无法设置任何断点。我怀疑这与未能设置任务文件有关。有什么建议吗?
当 VSCode检测tsc: build - tsconfig.json
到tsconfig.json
. 根据您的屏幕截图,我可以看出您已经拥有该文件。所以,如果检测不到就奇怪了。
请确保文件内容tsconfig.json
有效。
tsconfig.json
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"outDir": "out",
"sourceMap": true
}
}
Run Code Online (Sandbox Code Playgroud)
另外,要检查任务是否存在,您可以选择菜单“终端”->“运行构建任务”或在 MacOS 上按Shift + Command + B。如果正确,您可以看到两个可用的任务,如下图所示。
不然肯定是步骤有问题。也许,其中有一个额外的空格preLaunchTask
。作为参考,我也复制粘贴launch.json
在这里。
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceFolder}/helloworld.ts",
"preLaunchTask": "tsc: build - tsconfig.json",
"outFiles": [
"${workspaceFolder}/out/**/*.js"
]
}
]
}
Run Code Online (Sandbox Code Playgroud)
小智 8
我有类似的问题。就我而言,tsconfig.json 文件不在主文件夹中,而是在子文件夹中。就我而言,工作配置如下所示
{
"type": "node",
"request": "launch",
"name": "Launch server",
"program": "${workspaceFolder}/server/index.ts",
"preLaunchTask": "tsc: build - server/tsconfig.json",
"outFiles": ["${workspaceFolder}/out/**/*.js"]
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
10736 次 |
最近记录: |