React Native ERROR Packager无法在端口8081上侦听 [英] React native ERROR Packager can't listen on port 8081

查看:320
本文介绍了React Native ERROR Packager无法在端口8081上侦听的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

已经在我的Windows框上设置了React native,并且在运行react-native start时,它会不断向我显示此消息:

Have set up React native on my Windows box and it continually gives me this message when running react-native start:

错误打包程序无法在端口8081上监听

好,所以我按照说明将其更改为:

Ok, so I change it per instructions to:

本机启动--port = 8088

这很好用,我收到了:

[12/24/2016, 10:03:33 AM]         HMR Server listening on /hot
React packager ready.
[12/24/2016, 10:03:41 AM] <START> Initializing Packager
[12/24/2016, 10:03:41 AM] <START> Building in-memory fs for JavaScript
[12/24/2016, 10:03:41 AM] <END>   Building in-memory fs for JavaScript (103ms)
[12/24/2016, 10:03:41 AM] <START> Building Haste Map
[12/24/2016, 10:03:41 AM] <END>   Building Haste Map (64ms)
[12/24/2016, 10:03:41 AM] <END>   Initializing Packager (221ms)

按照指示,然后运行此命令:

So as instructed I then run this:

C:\ ReactProjects \ AwesomeProject> react-native run-android

并得到这个:

JS server not recognized, continuing with build...
Running C:\Users\<user>\AppData\Local\Android\sdk/platform-tools/adb -s emulator-5554 reverse tcp:8081 tcp:8081
Building and installing the app on the device (cd android && gradlew.bat installDebug)...
JS server not recognized, continuing with build...
Running C:\Users\<user>\AppData\Local\Android\sdk/platform-tools/adb -s emulator-5554 reverse tcp:8081 tcp:8081
Building and installing the app on the device (cd android && gradlew.bat installDebug)...
.
.
.
BUILD SUCCESSFUL
Total time: 19.304 secs
Starting the app on emulator-5554 (C:\Users\<user>\AppData\Local\Android\sdk/platform-tools/adb -s emulator-5554 shell am start -n com.awesomeproject/.MainActivity)...
Starting: Intent { cmp=com.awesomeproject/.MainActivity }

可悲的是,模拟器给了我

Sadly the emulator then gives me:

"Could not get BachedBridge, make sure your bundle is packaged correctly"

因此,有说明要求您必须更改仿真器上的端口,但我使用的是运行Marshmellow的Nexus 5,但找不到该设置:

So there are instructions that state you must change the port on the emulator, but I am using the Nexus 5 running Marshmellow and cannot find that setting:

     You will also need to update your applications to load the JavaScript bundle
     from the new port. Open the in-app Developer menu, then go to Dev Settings → Debug
 server host for device and replace 8081 with your port of choice.

任何人都知道如何设置仿真器以识别打包程序?

Anyone have an idea of how to set the emulator up to recognize the packager?

推荐答案

遗憾的是,Rect本机错误消息不那么用户友好. :(

Sadly the Rect native error messages are not that user friendly. :(

错误无法获取BachedBridge,请确保您的软件包正确包装"表示您的设备未连接到系统.

The error "Could not get BachedBridge, make sure your bundle is packaged correctly" means your device is not connected to your system.

基本上,当我们启动react-native时,它将东西部署到移动/仿真器中,但是当应用程序在移动/仿真器中运行时,它不知道从哪里需要提取代码素材,例如资产,捆绑包等.

Basically, when we start the react-native it deploy stuffs into the mobile/emulator, but when the app runs in mobile/emulator it does not know from where it need to pull code stuffs eg, assests, bundle packages etc.

因此,我们需要告诉仿真器,老板请从blah blah端口的blahblah服务器中挑选所有东西. 我们必须完全按照您在问题中提到的内容进行操作.

So, we need to tell emulator that, boss please pick all your stuffs from blahblah server at blah blah port. We have to do exactly what you have mentioned in the question.

打开应用内开发者菜单,然后转到开发设置→调试设备的服务器主机

Open the in-app Developer menu, then go to Dev Settings → Debug server host for device

好,所以我们需要完成两件事:

Ok so we need to achieve 2 things:

  1. 在模拟器中打开开发人员"菜单:

  1. Open Developer menu in emulator:

Developer菜单是一个模式弹出窗口,其中包含许多选项,例如Reload,远程调试JS,启用Live Reload,启用Hot Reload,Toggle Inspector ..., Dev Setting (这是一个我们有兴趣). 有很多方法可以做到这一点(如下所述),看看哪种方法对您有用

Developer menu is a modal pop up with bunch of options like, Reload, Debug JS Remotely, Enable Live Reload, Enable Hot Reload, Toggle Inspector ... , Dev Setting (this is the one we are interested in). There are number of ways to do that (mentioned below), see what works for you

  • 如果您是Mac用户,只需按CMD +M.它将为您打开一个弹出窗口
  • 如果您不是Mac,请尝试按CTRL + M
  • 对于某些按F2起作用的人. "fn + F2"
  • 如果您感到沮丧而没有任何效果,请尝试在终端下的命令下运行(显然是在模拟器启动时)
  • If you are Mac user simply press CMD + M. It will open up a pop up for you
  • If you are a non Mac try CTRL + M
  • For some people pressing F2 worked. "fn + F2"
  • If you are frustrated and nothing is working try running below command in terminal (obviously while the emulator is up) Running on Device:
adb shell input keyevent 82

  • 设置开发设置->调试设备的服务器主机和端口**

  • Set up Dev Settings -> Debug to server host and port for device**

    打开开发人员菜单"后,导航至开发设置->调试到设备的服务器主机和端口".

    After opening Developer Menu navigate to "Dev Settings -> Debug to server host and port for device".

    这个地方是解决您的问题的圣杯.

    This place is the holy grail for solution to your problem.

    获取您本机开始响应的机器IP地址和端口(即8088),然后在此处输入.看起来像"192.168.1.105:8088". 在此处签出图像链接

    Get your machine IP address and port where you have started react-native (i.e. 8088) and enter here. It will look something like "192.168.1.105:8088". Checkout the image link here

    单击确定"并重新加载应用程序(通过按两次R或在开发人员菜单"中单击重新加载"),然后就可以了.

    Click OK and reload the app (by pressing R twice or by clicking Reload in Developer Menu) and voila you are up.

    这篇关于React Native ERROR Packager无法在端口8081上侦听的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    相关文章
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆