如何在Visual Studio Code for React Native中设置调试?

问题描述 投票:10回答:2

我搜索了但除了Visual Studio Code文档之外我找不到任何外部来源,只是遵循这些文档不允许在iOS或Android中调试React Native应用程序。

我一直收到错误消息(这个用于Android,对于iOS类似:

[vscode-react-native] [警告]无法在http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false导入脚本。调试不起作用:尝试从应用程序内部重新加载JS,或重新连接VS Code调试器:path必须是一个字符串

我的launch.json文件为:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Debug Android",
            "program": "${workspaceRoot}/.vscode/launchReactNative.js",
            "type": "reactnative",
            "request": "launch",
            "platform": "android",
            "internalDebuggerPort": 9090,
            "sourceMaps": true,
            "outDir": "${workspaceRoot}/.vscode/.react"
        },
        {
            "name": "Debug iOS",
            "program": "${workspaceRoot}/.vscode/launchReactNative.js",
            "type": "reactnative",
            "request": "launch",
            "platform": "ios",
            "target": "iPhone 6s",
            "internalDebuggerPort": 9090,
            "sourceMaps": true,
            "outDir": "${workspaceRoot}/.vscode/.react"
        },
        {
            "name": "Attach to packager",
            "program": "${workspaceRoot}/.vscode/launchReactNative.js",
            "type": "reactnative",
            "request": "attach",
            "internalDebuggerPort": 9090,
            "sourceMaps": true,
            "outDir": "${workspaceRoot}/.vscode/.react"
        },
        {
            "name": "Debug in Exponent",
            "program": "${workspaceRoot}/.vscode/launchReactNative.js",
            "type": "reactnative",
            "request": "launch",
            "platform": "exponent",
            "internalDebuggerPort": 9090,
            "sourceMaps": true,
            "outDir": "${workspaceRoot}/.vscode/.react"
        }
    ]
}

我正在尝试在iOS模拟器或Android设备中进行调试,但该过程从不附加到外部JS调试器。

android ios debugging react-native visual-studio-code
2个回答
0
投票

您可以使用Vscode扩展“React native tools”来调试react-native应用程序。


0
投票

转到vscode中的debug选项并选择调试类型

  • 选择附加到打包器
  • 运行你的反应原生应用程序 qazxsw poi - >摇动手机并选择Debug remote JS选项 完成...
© www.soinside.com 2019 - 2024. All rights reserved.