You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

VSCode自动附加调试TypeScript时无法查看变量问题求助

调试TypeScript项目时变量无法检查的问题

我使用Yarn开发TypeScript项目,运行环境为Windows,通过VSCode连接WSL(已用code .打开存储在WSL分区的项目)。已将VSCode设置为智能自动附加调试模式,断点可正常命中,但无法检查变量(所有变量均显示undefined),在监视面板输入变量时会报错:Uncaught ReferenceError: VARIABLE_NAME is not defined。

相关配置信息

tsconfig.json:

{
    "compilerOptions": {
        "rootDir": "./src",
        "outDir": "./dist",
        "baseUrl": "./src",
        "module": "commonjs",
        "target": "es6",
        "lib": ["es6", "dom", "esnext"],
        "moduleResolution": "node",
        "sourceMap": true,
        "declaration": true,
        "declarationMap": true,
        "noImplicitAny": true,
        "noUnusedLocals": true,
        "noImplicitThis": true,
        "strictNullChecks": true,
        "noImplicitReturns": true,
        "preserveConstEnums": true,
        "esModuleInterop": true,
        "resolveJsonModule": true,
        "experimentalDecorators": true,
        "emitDecoratorMetadata": true
    },
    "include": ["**/*.ts"],
    "exclude": ["dist", "node_modules"]
}

项目构建命令:

esbuild src/index.ts --outfile=dist/index.js --bundle --platform=node --packages=external --minify --sourcemap --tsconfig=./tsconfig.json

内容的提问来源于stack exchange,提问作者Buisson

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.22 03:13:13