我正在使用Windows 10中的visual studio代码学习打字稿,我在运行简单程序时收到错误 “无法启动程序'E:\ typescriptBasis \ main.ts',因为无法找到相应的JavaScript。”因此我无法调试代码。
我安装了nodejs版本v10.2.1
我安装了npm版本v5.6.0
我在全球范围内安装了打字稿v2.8.3
我安装了Visual sudio代码v1.23.1
launch.json文件
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"sourceMaps": true,
"name": "Launch Program",
"program": "${workspaceFolder}/main.ts",
"outFiles": [
"${workspaceFolder}/**/*.js"
]
}
]
}
tsconfig.json文件
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"sourceMap": true
}
}
tasks.json
{
"version": "2.0.0",
"tasks": [
{
"type": "typescript",
"tsconfig": ".vscode\\tsconfig.json",
"option": "watch",
"problemMatcher": [
"$tsc-watch"
]
},
{
"type": "typescript",
"tsconfig": ".vscode\\tsconfig.json",
"problemMatcher": [
"$tsc"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
main.ts文件
console.log(“这是我的第一个打字稿程序”);
答案 0 :(得分:0)
我有以下用途 launch.json :
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"preLaunchTask": "TSC",
"program": "${file}",
"outFiles": [
"${workspaceFolder}/**/*.js"
]
}
]
}
tsconfig.json :
{
"compilerOptions": {
"target": "esnext",
"module": "commonjs",
"allowJs": false,
"sourceMap": true,
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"esModuleInterop": true
}
}
和 tasks.json :
{
"version": "2.0.0",
"tasks": [
{
"label": "TSC",
"type": "typescript",
"tsconfig": "tsconfig.json",
"problemMatcher": [
"$tsc"
]
}
]
}
我当前的VS Code版本是1.28.2