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

VS Code无法运行/调试代码,抛出“Cannot convert undefined or null to object”错误

VS Code调试/运行代码报错:Cannot convert undefined or null to object

问题详情

运行Python或JavaScript代码时,VS Code均抛出错误:"Cannot convert undefined or null to object"。已尝试清除用户/程序设置、重新安装VS Code,问题未解决。

当前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": [
    {
        "name": "Python: Current File",
        "type": "python",
        "request": "launch",
        "program": "${file}",
        "console": "integratedTerminal",
        "justMyCode": true
    }
]

问题截图:
问题截图1
问题截图2

解决步骤

  • 检查终端环境变量:打开集成终端,执行echo $PATH(Linux/macOS)或echo %PATH%(Windows),确认Python、Node.js的可执行路径存在且有效。路径缺失的话,手动添加对应语言安装目录到系统环境变量,重启VS Code。
  • 排查扩展冲突:按Ctrl+Shift+X打开扩展面板,点击右上角三点选择「禁用所有已安装扩展」,重启后测试代码运行。若问题消失,逐个启用扩展找出冲突项。
  • 重置终端配置:打开VS Code设置,搜索terminal.integrated.defaultProfile,切换为系统默认终端(如Windows的命令提示符、macOS的Terminal),重启后重试。
  • 重置工作区配置:备份项目根目录下的.vscode文件夹后删除,重新生成launch.json和settings.json。
  • 修复VS Code安装:切换至内部人员版本,或下载最新稳定版覆盖安装,确保安装包完整。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.30 09:23:39