gpt4 book ai didi

debugging - 无法在 VSCode 中调试 Typescript

转载 作者:搜寻专家 更新时间:2023-10-30 20:56:14 25 4
gpt4 key购买 nike

这是我的 launch.json

    "version": "0.2.0",
"configurations": [
{
"type": "node",
"name": "Launch Server",
"request": "launch",
"program": "${workspaceRoot}/server/src/app.ts",
"cwd": "${workspaceRoot}",
"env": {
"NODE_ENV": "dev"
},
"skipFiles": [
"node_modules/**/*.js"
],
"outFiles": [
"${workspaceRoot}/dist/server/src/*.js"
],
"sourceMaps": true,
"stopOnEntry": true,
"console": "internalConsole"
},

我的源文件夹:

enter image description here

我的 dist 文件夹:

enter image description here

我得到的错误是:

Cannot launch program '/Dev/myapp/server/src/app.ts'; setting the 'outFiles' attribute might help.

如果我将“程序”属性更改为“”程序”:“${workspaceRoot}/dist/server/src/app.js”,它可以工作,但我随后调试的是转译的 javascript 而不是 typescript 。显然使用 .map 文件进行转译是有效的,有什么问题吗?

tsconfig.json

{
"compilerOptions": {
"allowJs": false,
"baseUrl": "",
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [
"es6",
"dom"
],
"mapRoot": "./",
"module": "commonjs",
"moduleResolution": "node",
"outDir": "./dist",
"sourceMap": true,
"target": "es6",
"typeRoots": [
"node_modules/@types"
]
},
"exclude": [
"web",
"dist",
"node_modules"
]
}

最佳答案

您的配置中缺少 src 文件夹:

"outFiles": [
"${workspaceRoot}/dist/server/src/*.js"
],

同时将 tsconfig.json 中的 mapRoot 设置为 ./dist/。目前它将在您的 ./server/src 文件夹中搜索 sourcemaps 而不是 ./dist

关于debugging - 无法在 VSCode 中调试 Typescript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42747618/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com