【发布时间】:2020-09-10 13:21:42
【问题描述】:
我看了这么多教程,它们看起来很简单,但我就是无法让调试工作(运行 Expo,还没准备好弹出,这完全是另一个级别的疯狂)。
我尝试使用create-react-native-app 和expo-init 创建一个应用程序,这似乎是同一件事。我开始使用yarn start 运行该应用程序,我可以在 Expo 中看到该应用程序。我在 VSCode 中选择“附加到打包程序”,每次都失败。
我已将 "react-native.packager.port": 19005 添加到我的 settings.json 中,但我似乎找不到正确的端口。我的 Metro 屏幕在这么多不同的地方有这么多不同的端口:
- 我运行
yarn start的终端说
Expo DevTools is running at http://localhost:19003
Opening DevTools in the browser... (press shift-d to disable)
Starting Metro Bundler on port 19005.
Successfully ran `adb reverse`. Localhost URLs should work on the connected Android device.
Tunnel ready.
exp://192.168.1.5:19004
- 镀铬窗口位于
localhost:19003 - Metro Bundler 终端的第一行写着
Starting Metro Bundler on port 19005. - 稍后在终端显示
Opening exp://127.0.0.1:19004 in iOS simulator - 在侧边栏中显示
exp://192.168.1.5:19004,这反映在 iOS 模拟器的开发设置屏幕中。
我尝试将"react-native.packager.port": 19005 中的端口更改为 19000 到 19005 之间的每个数字,但都失败了。他们都说:
Could not debug. Cannot attach to packager.
Are you sure there is a packager and it is running in the port 19003?
If your packager is configured to run in another port make sure to add that to the settings.json. (error code 504)
当然是当前设置的端口。
帮帮我!!!
【问题讨论】:
-
我也面临同样的问题。你解决了吗?
标签: react-native visual-studio-code