ReactNative常见错误

2017-03-10  本文已影响25人  有一种再见叫青春

Packager can't listen on port 8081

You can configure the packager to use a port other than 8081 by using theportparameter:

$ react-native start --port=8088

You will also need to update your applications to load the JavaScript bundle from the new port.

To change the port used by an iOS application, edit the AppDelegate.m file in the ios folder. Scroll down to the line where the bundle location is defined, and replace 8081 with the new port.

js CodeLocation=[NSURL URLWithString:@"http://localhost:8088/index.ios.bundle"];

若上面二种方式不好使,可以采用如下方式

1.在React Native项目根目录下运行 npm start

2.使用curl命令生成 main.jsbundle

curlhttp://localhost:8081/index.ios.bundle -o main.jsbundle

3.在AppDelegate.m中选择使用main.jsbundle注释掉

jsCodeLocation= [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle?platform=ios&dev=true"];

修改8081端口号即可

上一篇 下一篇

猜你喜欢

热点阅读