[英]React native not running on localhost
React native stopped working, whenever I run it now (no matter which project) I get the error could not connect to development server | React Native停止工作,无论何时运行(无论哪个项目),我都收到错误,无法连接到开发服务器| ensure the following node server is running and available on the same network - run npm start from react native root.
确保以下节点服务器正在同一网络上运行并可用-从反应本机根目录运行npm start。
Node server url is correctly set in appdelegate 在appdelegate中正确设置了节点服务器URL
URL : http://localhost:8081/index.ios.bundle ? 网址: http:// localhost:8081 / index.ios.bundle ? platform=ios&dev=false
平台= iOS和开发= FALSE
I usually just run npm start in my terminal. 我通常只是在终端上运行npm start。 (OSX) I assume it would be the same on Windows
(OSX)我认为在Windows上也一样
npm start
To debug on a real device: 要在真实设备上调试:
On iOS - open the file AppDelegate.m and change localhost to the IP address of your computer. 在iOS上-打开文件AppDelegate.m,然后将localhost更改为计算机的IP地址。 Shake the device to open the development menu with the option to start debugging.
摇动设备以打开开发菜单,并带有开始调试的选项。
let jsCodeLocation = NSURL(string: "http://{{YOUR IP ADRESS}}:8081/index.bundle?platform=ios")
Please ensure you have done the following 请确保您已完成以下操作
1) run server using 1)使用运行服务器
npm start
2) if you are using actual device , make sure you are connected to same network 2)如果您使用的是实际设备,请确保您已连接到同一网络
3) for android: run the following command and try again 3)对于android:运行以下命令,然后重试
adb reverse tcp:8081 tcp:8081
I was face same problem while running in physical device. 在物理设备上运行时,我遇到了同样的问题。
I did as below: 我做了如下:
note: cross check in browser ip along with port number. 注意:交叉检查浏览器ip和端口号。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.