首页 > 解决方案 > 调试本机反应时出错?

问题描述

我正在尝试调试我的反应本机应用程序,但出现以下错误。 在此处输入图像描述

TypeError [ERR_INVALID_PROTOCOL]: Protocol "localhost:" not supported. Expected "http:". Debugging won't work: Try reloading the JS from inside the app, or Reconnect the VS Code debugger: Couldn't import script at <localhost:8081/Users/sandesh/Library/Developer/CoreSimulator/Devices/85B2AD76-7F82-48EC-AF36-B10C5DE8E783/data/Containers/Bundle/Application/B7545C06-A275-410D-9C57-C62B1931AF3C/eRamp.app/bundle/index.ios.jsbundle> (error code 1408)

launch.json 如下

 "version": "0.2.0",
    "configurations": [
    
        {
            "name": "Debug iOS ete",
            "cwd": "${workspaceFolder}",
            "type": "reactnative",
            "request": "launch",
            "platform": "ios",

            "env": {
                "ENVFILE": ".env.ete"
            }
        },

        {
            "name": "Debug Android ete",
            "cwd": "${workspaceFolder}",
            "type": "reactnative",
            "request": "launch",
            "platform": "android",
            
            "env": {
                "ENVFILE": ".env.ete"
            }
        },

标签: react-nativedebugging

解决方案


要在本机反应中启用调试,
如果您在模拟器中按 Ctrl + M 或者如果在您的设备中摇动它,将出现一个对话框,您将在其中看到“调试”选项,只需按下它,您将自动被重定向到您的网络浏览器。
Ctrl + Shift + I开始调试。


推荐阅读