我按照 VSCode 中的调试说明进行操作
https://github.com/Microsoft/vscode-react-native
我将带有 USB 线的 Nexus 6P 与 MBP2015 连接起来,并启用了开发者选项和 USB 调试,但是当我在 VSC 中选择“调试 Android”时,我得到了此信息
[Error] "Could not debug. Android project not found."
我也附上了这张照片。
如果我想在 IOS 模拟器上进行调试,我在 VSC 中选择“调试 IOS”,但随后我得到了此消息,并且模拟器未启动
[vscode-react-native] Prewarming bundle cache. This may take a while ...
[vscode-react-native] Building and running application.
[vscode-react-native] Executing command: react-native run-ios --simulator
Scanning 772 folders for symlinks in /Users/me/reactnativework/my-app/node_modules (4ms)
ENOENT: no such file or directory, uv_chdir
[Error] "Could not debug. Error while executing command 'react-native run-ios --simulator': Error while executing command 'react-native run-ios --simulator'"
我在这里看到了一些关于类似问题的帖子,但没有一个得到解答,或者与我遇到的问题不同。
如何使用断点调试最简单的 React Native 应用程序,以便我可以跟踪代码在 Visual Studio 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": "Debug Android",
"program": "${workspaceRoot}/.vscode/launchReactNative.js",
"type": "reactnative",
"request": "launch",
"platform": "android",
"sourceMaps": true,
"outDir": "${workspaceRoot}/.vscode/.react"
},
{
"name": "Debug iOS",
"program": "${workspaceRoot}/.vscode/launchReactNative.js",
"type": "reactnative",
"request": "launch",
"platform": "ios",
"sourceMaps": true,
"outDir": "${workspaceRoot}/.vscode/.react"
},
{
"name": "Attach to packager",
"program": "${workspaceRoot}/.vscode/launchReactNative.js",
"type": "reactnative",
"request": "attach",
"sourceMaps": true,
"outDir": "${workspaceRoot}/.vscode/.react"
},
{
"name": "Debug in Exponent",
"program": "${workspaceRoot}/.vscode/launchReactNative.js",
"type": "reactnative",
"request": "launch",
"platform": "exponent",
"sourceMaps": true,
"outDir": "${workspaceRoot}/.vscode/.react"
}
]
}
最佳答案
关于在 Visual Studio Code 中调试?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46654585/