我有一个 expo 项目,我们可以运行和构建它,它可以在 android 和 iOS 中正常工作。我想要的是使用我的 Visual Studio Code 调试所述项目。
我遵循了一些指南并尝试了以下方法:
- 在 vscode 中添加 React Native Tools 扩展。
- 在 vscode 调试器中添加“附加到打包程序”配置。
- 更改 settings.json 中的“react-native.packager.port”以匹配 expo 打包程序端口 (19001)
- 运行博览会(博览会开始)
- 并尝试通过启用和禁用“远程调试 JS”以及打开或关闭 chrome 调试器来启动调试器
我得到的结果是带有调试器控件的小窗口出现了一秒钟然后消失,没有任何日志或证据表明它做了什么。我检查了 vscode 中的终端选项卡、输出选项卡和调试控制台选项卡
顺便说一句,当我启用“远程调试 JS”时,chrome 调试器会启动并完美运行。
我的 launch.json 是由 react native tools 扩展自动生成的。我还尝试将 "sourceMaps":true 添加到附加配置中,最终结果是相同的。这是我的代码:
{
// 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": "Debug Android",
"cwd": "${workspaceFolder}",
"type": "reactnative",
"request": "launch",
"platform": "android"
},
{
"name": "Debug iOS",
"cwd": "${workspaceFolder}",
"type": "reactnative",
"request": "launch",
"platform": "ios"
},
{
"name": "Attach to packager",
"cwd": "${workspaceFolder}",
"type": "reactnative",
"request": "attach"
},
{
"name": "Debug in Exponent",
"cwd": "${workspaceFolder}",
"type": "reactnative",
"request": "launch",
"platform": "exponent"
}
]
}
以防万一,操作系统是 Ubuntu 16.04
提前致谢!