鍍金池/ 問答/HTML5  iOS  HTML/ react-native環(huán)境搭建遇阻

react-native環(huán)境搭建遇阻

按照react-native中文網(wǎng)的教程在mac上搭建react-native的環(huán)境

react-native init AwesomeProject
cd AwesomeProject
react-native run-ios

做到了這步
提示如下

Connection to localhost port 8081 [tcp/sunproxyadmin] succeeded!

**Port 8081 already in use, packager is either not running or not running correctly
Command /bin/sh failed with exit code 2**

網(wǎng)上找到的方案是在 AppDelegate.m 中,
Change

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

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

#import "AppDelegate.h"

#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  NSURL *jsCodeLocation;

  jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];

  RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
                                                      moduleName:@"AwesomeProject"
                                               initialProperties:nil
                                                   launchOptions:launchOptions];
  rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];

  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  UIViewController *rootViewController = [UIViewController new];
  rootViewController.view = rootView;
  self.window.rootViewController = rootViewController;
  [self.window makeKeyAndVisible];
  return YES;
}

@end

我的AppDelegate.m如上
但并沒有找到 http://....8081
執(zhí)行了另一個回答中的方案sudo lsof -n -i4TCP:8081
依然還是**Port 8081 already in use, packager is either not running or not running correctly
Command /bin/sh failed with exit code 2**
不知路在何方,求大神們指點一二,不勝感激,跪謝

回答
編輯回答
憶往昔

我也是這個問題,init的0.44.3版本react-native。改了server的port,代碼里的8081也都改了,報錯還是跟上面一樣8081.請問你解決了嗎

2017年10月29日 07:30