CocosCreator VSCode调试时报Unable to find an installation of the browser on your system

前提

根据VSCode配置调试环境 | Cocos 文档配置VSCode调试环境。

问题

Cocos Creator项目在VSCode中运行F5调试时报找不到浏览器

Unable to launch browser:"Unable to find an installation of the browser on your
system.Try installing it,or providing an absolute path to the browser in the
"runtimeExecutable"in your launch.json."

在这里插入图片描述

解决方法

launch.json中添加runtimeExecutable配置浏览器绝对路径:

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "chrome",
            "request": "launch",
            "name": "Cocos Creator Launch Chrome against localhost",
            "url": "http://localhost:7456",
            "webRoot": "${workspaceFolder}",
            // 提供浏览器绝对路径
            "runtimeExecutable": "C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe"
        }
    ]
}
### VSCode 调试 C++ 时遇到 "Unable to start debugging" 错误的解决方案 当尝试通过 F5 运行并调试 C++ 程序时,如果收到错误消息 `Unable to start debugging. Program path '***.exe' is missing or invalid` 或者更具体的 `GDB failed with message: "***.exe": not in executable format: File format not recognized`, 可能是因为几个原因造成的。 #### 配置文件设置不当 确保项目根目录下的 `.vscode/launch.json` 和 `.vscode/tasks.json` 文件配置无误。通常情况下,这些 JSON 文件定义了如何构建和启动应用程序的过程。对于 C++ 开发而言,常见的任务是调用 g++ 编译器来创建可执行文件[^1]。 ```json // launch.json example configuration for a simple C++ project using GDB debugger. { "version": "0.2.0", "configurations": [ { "name": "(gdb) Launch", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/a.out", // Ensure this points correctly at your compiled binary "args": [], "stopAtEntry": false, "cwd": "${fileDirname}", "environment": [], "externalConsole": true, "MIMode": "gdb", "setupCommands": [ { "description": "Enable pretty-printing for gdb", "text": "-enable-pretty-printing", "ignoreFailures": true } ], "preLaunchTask": "build hello world", // Make sure you have defined this task in tasks.json "miDebuggerPath": "/path/to/gdb" } ] } ``` #### 构建过程失败或未完成 另一个常见问题是实际并没有成功生成目标二进制文件 (`*.exe`) 。这可能是由于编译过程中存在语法或其他类型的错误阻止了最终输出物被正确生产出来。因此,在尝试启动调试会话之前,请先单独验证能否正常编译源码: ```bash # Example command line compilation check outside of VS Code $ cd /path/to/project/ $ g++ main.cpp -o my_program ``` #### 执行权限不足 有时即使有有效的 .exe 文件,也可能因为缺少必要的读写权限而无法加载它作为进程映像。检查是否有足够的访问权去读取该位置上的任何资源,并确认操作系统允许执行此特定文件类型。 #### 使用正确的工具链选项 某些开发者可能会不小心选择了不匹配当前项目的模板或者预设环境变量,比如选择了 cpp.exe 而不是预期中的 g++.exe 来处理 C++ 源代码。务必核实所使用的命令行参数以及关联的解释器是否适合手头的任务需求[^4]。 #### 清理缓存重试 最后可以考虑清理本地缓存数据后再做一次完整的重新安装操作;有时候残留的历史记录会影响新版本软件的表现形式。重启计算机也是一个简单有效的方法来排除临时性干扰因素的影响。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值