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+Don Mac,Ctrl+Mon 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 underchrome://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://inspectin 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 addlocalhost:8081to 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+Cin the terminal) and restart it withnpx 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 :8081to find the process ID, thenkill -9 <PID> - On Windows: Run
netstat -ano | findstr :8081to get the PID, thentaskkill /F /PID <PID>
After killing the process, restart Metro and debugging.
- On Mac/Linux: Run
- 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
相关产品推荐
相关产品推荐

