编译RN整合到 taro-native-shell 后无法启动



  • 条件和步骤如下:

    1. taro-cli版本1.2.26,node版本10.15.3,yarn版本1.16.0
    2. 微信构建正常,H5构建正常
    3. RN构建8081端口js代码正常呈现
    4. 整合到taro原生 React Native 壳子,react-native run-android启动,端口构建失败,安卓模拟器报错code500

    模拟器报错信息大致是这样,
    the development server returned response error code:500
    URL: http://10.0.3.2:8081/index.delta?platform=android&dev=true&minify=false


    经测试,native官方的组件页面,直接命名为app.js,可正常渲染呈现

    将官方组件页面,单独放入taro构建出来的app.js路由中,可正常渲染呈现

    然而将taro构建的其他页面放入路由,模拟器直接就是红屏code500!


    整合后的模块依赖

    "dependencies": {
        "@tarojs/components-rn": "^1.2.26",
        "@tarojs/taro-rn": "^1.2.26",
        "@tarojs/taro-router-rn": "^1.2.26",
        "@tarojs/taro-redux-rn": "^1.2.26",
        "react": "16.3.1",
        "react-native": "0.55.4",
        "redux": "^4.0.0",
        "tslib": "^1.8.0",
        "@tarojs/components": "1.2.26",
        "@tarojs/router": "1.2.26",
        "@tarojs/taro": "1.2.26",
        "@tarojs/taro-alipay": "1.2.26",
        "@tarojs/taro-h5": "1.2.26",
        "@tarojs/taro-swan": "1.2.26",
        "@tarojs/taro-tt": "1.2.26",
        "@tarojs/taro-weapp": "1.2.26",
        "nerv-devtools": "^1.3.9",
        "nervjs": "^1.3.9",
        "stylelint": "9.0.0",
        "stylelint-config-taro-rn": "1.2.26",
        "stylelint-taro-rn": "1.2.26"
      },
      "devDependencies": {
        "@babel/core": "^7.3.4",
        "@babel/runtime": "^7.3.4",
        "@commitlint/cli": "^7.5.2",
        "@commitlint/config-conventional": "^7.5.0",
        "babel-jest": "^24.5.0",
        "conventional-changelog-cli": "^2.0.12",
        "husky": "^1.3.1",
        "jest": "^24.5.0",
        "metro-react-native-babel-preset": "^0.53.1",
        "react-test-renderer": "16.8.3"
      },
    


  • 看起来应该是模拟器访问到 server ,只不过返回 500 错误。那 Metro Bundler 页面的日志有报错吗?



  • @蜘蛛paipai

    Error: "Unable to resolve module ./index.scss

    另外之前构建RN的时候,有报样式会被RN忽略,但js bundle是正常呈现的

    备注掉scss引入,会报Metro Bundler has encountered an internal error, please check your terminal error output for more details



  • @漫太古 所以 terminal error output 是什么?



  • @蜘蛛paipai

    error: bundling failed: Error: While trying to resolve module weui from file C:\Users\Administrator\Desktop\taro-native-shell-master\node_modules\@tarojs\components\dist\index.js, the package C:\Users\Administrator\Desktop\taro-native-shell-master\node_modules\weui\package.json was successfully found. However, this package itself specifies a main module field that could not be resolved



  • weui 这个包有问题?



  • @蜘蛛paipai 目前终端里面报的就是这个,然而并不知道是不是准确



  • @漫太古 请问如何整合到taro原生 React Native 壳子。react native中文网看不太明白。可以详细说明一下嘛



  • @zox 才看到,不知道你弄好没。。我是把.rn_temp里面的文件拖到壳子根目录了,壳子里面原本有的该咋样还是咋样,除了package我是把.rn_temp里面的依赖复制添加到壳子的package里,再统一npm i



  • @漫太古 按照你的方法我试了一下。

    react-native run-ios
    

    运行后停滞了。如图
    屏幕快照 2019-06-18 下午1.31.45.png


登录后回复