ReactNative常见错误

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端口号即可

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容