elone
V2EX  ›  React

react native 升级告负,认命,回退到 0.44

  •  
  •   elone · Jul 9, 2017 · 3889 views
    This topic created in 3249 days ago, the information mentioned may be changed or developed.

    想把 rn 升级到 0.46 ,结果遇到了个疑难杂症,提问无解,白白浪费了一天一夜,我美好的周末。

    提问帖: https://www.v2ex.com/t/374118 https://stackoverflow.com/questions/44994935/react-native-android-syntaxerror-attempted-to-redefine-property-filesystem

    升级强迫症的我,认输啊。

    想问一下大家 ,你们都是怎么升级 rn 的?有没有无痛的办法? 感觉很要命啊,升级一下 rn, 其它想关联的库也要一并调整到对应的版本,不然就完全跑不起来了。

    5 replies    2017-07-16 10:58:19 +08:00
    wee911
        1
    wee911  
       Jul 10, 2017
    RN 项目所有的包都去掉^, RN 随意一个坑都要弄一天
    cubesugar
        2
    cubesugar  
       Jul 10, 2017   ❤️ 1
    一般步骤是:
    1 删掉 node_modules 目录
    2 修改 package.json 里版本号
    3 npm install

    0.44 ~> 0.45 这么升了一次,目前没出什么问题。
    elone
        3
    elone  
    OP
       Jul 13, 2017
    @cubesugar #2 官方似乎完全不推荐这种方法进行升级。我有试过这种方法升级到 0.45 ,当时也失败了。
    cubesugar
        4
    cubesugar  
       Jul 16, 2017
    @elone 1

    周末升级了 0.46.3,趟了一些坑,这次是从 0.44.3 -> 0.46.3 的升级,最后的步骤如下:

    1 react-native-git-upgrade --npm // 默认使用 yarn 可能因为网络问题始终失败

    2 如果使用了 cocoapods,删除 ./ios/Pods,然后 pod install // 因为第一次打开时候,pod 工程加载失败了

    3 修改 Build Phases 里 Bundle React Native code and images 的脚本路径:
    ../node_modules/react-native/scripts/react-native-xcode.sh

    4 Linked Frameworks and Libraries 里 添加 libyoga.a libdouble-conversion.a libthird-party.a 等缺失的 lib

    这时候应该就可以编译通过了
    cubesugar
        5
    cubesugar  
       Jul 16, 2017
    @elone 还有就是彻底清除 DerivedData 和 ./ios/build , clean proj
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3448 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 11:31 · PVG 19:31 · LAX 04:31 · JFK 07:31
    ♥ Do have faith in what you're doing.