我正在 Windows 10 中使用 Visual Studio 代码学习打字稿,但运行简单程序时出错。
“无法启动程序 'E:\typescriptBasis\main.ts',因为找不到相应的 JavaScript。” 因此我无法调试代码。
我已经安装了 nodejs 版本 v10.2.1
我已经安装了 npm 版本 v5.6.0
我已经全局
安装了 typescript v2.8.3我已经安装了 Visual sudio code 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"
]
}
]
}
Run Code Online (Sandbox Code Playgroud)
tsconfig.json 文件
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"sourceMap": true
}
}
Run Code Online (Sandbox Code Playgroud)
任务文件
{
"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
}
}
]
}
Run Code Online (Sandbox Code Playgroud)
main.ts 文件
console.log("这是我的第一个打字稿程序");
我让它与以下 launch.json一起使用:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"preLaunchTask": "TSC",
"program": "${file}",
"outFiles": [
"${workspaceFolder}/**/*.js"
]
}
]
}
Run Code Online (Sandbox Code Playgroud)
tsconfig.json:
{
"compilerOptions": {
"target": "esnext",
"module": "commonjs",
"allowJs": false,
"sourceMap": true,
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"esModuleInterop": true
}
}
Run Code Online (Sandbox Code Playgroud)
和tasks.json:
{
"version": "2.0.0",
"tasks": [
{
"label": "TSC",
"type": "typescript",
"tsconfig": "tsconfig.json",
"problemMatcher": [
"$tsc"
]
}
]
}
Run Code Online (Sandbox Code Playgroud)
我当前的 VS Code 版本是 1.28.2
归档时间: |
|
查看次数: |
5452 次 |
最近记录: |