这是我运行react-native start
时得到的输出,正如您所看到的,它给出了404错误。
我尝试用chrome打开页面,然后显示Cannot GET /
。
即使在通过wifi连接设备并输入机器的IP地址之后,应用程序也无法在移动设备上运行。它被卡在红色屏幕上Unable to load JS Bundle.
出了什么问题?
C:\Users\Abhishek\Desktop\SpeedRead>react-native start
┌────────────────────────────────────────────────────────────────────────────┐
│ Running packager on port 8081. │
│ │
│ Keep this packager running while developing on any JS projects. Feel │
│ free to close this tab and run your own packager instance if you │
│ prefer. │
│ │
│ https://github.com/facebook/react-native │
│ │
└────────────────────────────────────────────────────────────────────────────┘
Looking for JS files in
C:\Users\Abhishek\Desktop\SpeedRead
[3:25:35 PM] <START> Building Dependency Graph
[3:25:35 PM] <START> Crawling File System
[3:25:35 PM] <START> Loading bundles layout
[3:25:35 PM] <END> Loading bundles layout (0ms)
React packager ready.
[3:25:44 PM] <END> Crawling File System (9096ms)
[3:25:44 PM] <START> Building in-memory fs for JavaScript
[3:25:45 PM] <END> Building in-memory fs for JavaScript (554ms)
[3:25:45 PM] <START> Building in-memory fs for Assets
[3:25:45 PM] <END> Building in-memory fs for Assets (521ms)
[3:25:45 PM] <START> Building Haste Map
[3:25:46 PM] <START> Building (deprecated) Asset Map
[3:25:46 PM] <END> Building (deprecated) Asset Map (95ms)
[3:25:49 PM] <END> Building Haste Map (3482ms)
[3:25:49 PM] <END> Building Dependency Graph (13858ms)
::1 - - [31/Jan/2016:09:56:19 +0000] "GET / HTTP/1.1" 404 13 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.97 Safari/537.36"
::1 - - [31/Jan/2016:09:56:19 +0000] "GET /favicon.ico HTTP/1.1" 404 24 "http://localhost:8081/" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.97 Safari/537.36"
我看过的问题:
react native android failed to load JS bundle
但它没有用。
答案 0 :(得分:0)
如果您想确保打包者正在加载,则需要导航到http://localhost:8081/js/index.android.bundle?platform=android
。如果您仍然获得404,那么您的网络配置很可能出现问题。
如果您可以在网络上启动它,请在手机通过USB adb reverse tcp:8081 tcp:8081
插入手机的情况下运行。