美文网首页
react-native 8081端口占用 error!!!

react-native 8081端口占用 error!!!

作者: 折木丶青梵 | 来源:发表于2019-03-13 19:01 被阅读0次

    当你用Xcode run react-native-cli init出来的项目时,可能会发生默认端口8081被占用的情况,如下图:


    image.png

    解决方案:
    1:查找占用8081端口的罪魁祸首,然后直接删除
    方法:打开终端,输入命令lsof -i:8081,找到端口号对应的程序,再直接kill掉。

    2:改变react native 监听端口的方法
    a.在终端进入项目文件夹运行:react-native start --port 8889;
    b.xcode里search所有的8081,将它们替换为8889;
    c.xcode里找到Libiaries/React.xcodeproj/Build Phases/Run Scripts,替换掉8081,操作完运行就正常了。


    image.png

    相关文章

      网友评论

          本文标题:react-native 8081端口占用 error!!!

          本文链接:https://www.haomeiwen.com/subject/yvotmqtx.html