You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

React Native调试开启方式确认及Chrome控制台无代码显示求助

Hey there! Let's break down your two React Native debugging questions clearly:

1. 如何确认React Native是否已开启调试?

You can verify if debugging is active in a few straightforward ways:

  • Check the debug menu: On your emulator/device, shake the device (or press Cmd+D on Mac, Ctrl+M on Windows/Linux) to bring up the developer menu. If "Debug JS Remotely" has a checkmark next to it, debugging is enabled.
  • Look for the debug banner: When debugging is active, your app will show a red banner at the top that says "Debugger connected".
  • Check Chrome's debugger interface: If debugging is on, a new Chrome window (or tab) should open pointing to http://localhost:8081/debugger-ui/ or be visible under chrome://inspect > "Devices" section.
2. 开启调试后Chrome控制台代码无法显示?试试这些解决方法

If the Chrome console isn't showing your app's code, here are actionable fixes to try:

  • Refresh the Chrome debugger window: Sometimes the initial connection glitches. Close the debugger tab/window, disable then re-enable "Debug JS Remotely" from the RN dev menu, and let the debugger reopen.
  • Verify the inspect target: Open chrome://inspect in Chrome. Under "Devices", you should see your React Native app listed. Click "inspect" next to it—if it's not showing, click the "Configure" button and add localhost:8081 to the target list.
  • Disable Chrome extensions: Privacy-focused extensions (like ad blockers, VPNs, or script blockers) often interfere with the RN debugger. Temporarily disable all extensions, then restart the debugger.
  • Clear Chrome's site data for localhost: Go to Chrome's settings > Privacy and security > Site Settings > View permissions and data stored across sites. Search for localhost, delete its data, then re-launch the debugger.
  • Restart the Metro bundler: If the Metro server crashed or froze, close it (press Ctrl+C in the terminal) and restart it with npx react-native start. Then re-enable debugging.
  • Check for port conflicts: The default RN debug port is 8081. If another app is using it, kill that process:
    • On Mac/Linux: Run lsof -i :8081 to find the process ID, then kill -9 <PID>
    • On Windows: Run netstat -ano | findstr :8081 to get the PID, then taskkill /F /PID <PID>
      After killing the process, restart Metro and debugging.
  • Update React Native and Chrome: Outdated versions can cause compatibility issues. Upgrade your RN project to the latest stable version, and make sure Chrome is updated to its newest release.

内容的提问来源于stack exchange,提问作者Alex

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 03:26:43