在React Native中调试时遇到错误?

时间:2020-10-14 09:58:17

标签: react-native debugging

我正在尝试调试我的React本机应用程序,但出现以下错误。 enter image description here

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"
            }
        },

1 个答案:

答案 0 :(得分:0)

要在react native中启用调试,
如果您在仿真器中,请按Ctrl + M,或者如果在您的设备中仅将其摇晃,则会出现一个对话框,您将在其中看到Debug选项,只需按一下,然后ll将自动重定向到您的Web浏览器。
Ctrl + Shift + I 开始调试。