本文介绍了React Native - 端口 8081 已在使用,打包程序未运行或未正确运行命令/bin/sh 失败,退出代码 2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我正在尝试启动并运行 React Native,我在 Xcode 中看到以下消息:

端口 8081 已被使用,打包程序未运行或未正确运行

命令/bin/sh 失败,退出代码 2

我访问了

任何帮助将不胜感激.

解决方案

借助其他人的回答.我尝试了以下步骤.它对我有用,并希望对其他人有用.它仅适用于 iOS.假设我们要将 8081 端口更改为 8999 端口.

首先,打开 Xcode.

  • 看项目导航器(左)在[项目名称]/[项目名称]/AppDelegate.m:

    改变

    http://localhost:8081/index.ios.bundle?platform=ios&dev=true

    http://localhost:8999/index.ios.bundle?platform=ios&dev=true

  • 在项目导航器(左)[项目名称]/库中:

    点击React.xcodeproj".在主面板上,点击Build Phases"标签.

    展开运行脚本",用叉号将其删除.

  • 在项目导航器中(左)[项目名称]/库/RCTWebSocket.xcodeproj/RCTWebSocketExecutor.m :搜索 8081 和替换为 8999

第二次打开 Finder

在项目根目录中,打开package.json":

将脚本"属性更改为:

{...开始":node_modules/react-native/packager/packager.sh --port=8999"...}

然后打开终端

  • $cd 到项目根目录:

    $ npm start

酷!那么

返回 Xcode 并单击播放按钮.

交叉你的手指.

要有耐心.客户端会有一片空白.

您可以看到它正在后端构建(终端会记录它).

I'm trying to get up and running with React Native and I am seeing the message below in Xcode:

I went to the React Native troubleshooting page and tried to kill the port 8081 processes, but I'm still getting the same issue.

Here is a screenshot of what I am seeing in Xcode:

Any help would be fully appreciated.

解决方案

With the help of other people's answers. I tried the following steps. It worked for me and hopefully for others. It only works for iOS.Let’s say we want to change the 8081 port to 8999 port.

First, Open Xcode.

  • Look at Project navigator(left) In[ProjectName]/[ProjectName]/AppDelegate.m:

    Change

    http://localhost:8081/index.ios.bundle?platform=ios&dev=true
    

    to

    http://localhost:8999/index.ios.bundle?platform=ios&dev=true
    

  • In Project navigator(left) [ProjectName]/ Libraries:

    Click "React.xcodeproj". On main panel, click "Build Phases" tag.

    Expand "Run Script", delete it with the cross.

  • In Project navigator(left) [ProjectName] / Libraries /RCTWebSocket.xcodeproj / RCTWebSocketExecutor.m : Search 8081 andreplace it with 8999

Second open Finder

In the project root, open "package.json" :

Change the "script" attribute to :

{...

    "start": "node_modules/react-native/packager/packager.sh --port=8999"
...
}

Then Open terminal

  • $cd to project root :

    $ npm start

Cool! Then

Go back to Xcode and click the play button.

Cross your fingers.

Be Patient. There will be a blank in the client.

You can see it is doing building on the backend(terminal will log it).

这篇关于React Native - 端口 8081 已在使用,打包程序未运行或未正确运行命令/bin/sh 失败,退出代码 2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 13:18