RN和H5集成taro-ui后报错



  • 我在项目中,集成taro-ui后,就会报错:“The module ./components/calendar could not be found”。新项目和已经开发了一阵子的单窗口项目都会出现这个问题,rn和h5都有,其他还没试。请问这是怎么回事?怎么能解决一下?谢谢
    复现方式:新建项目,或成功运行的项目,运行yarn add taro-ui,之后使用taro-ui的控件进行开发;
    复线概率:每次都复现,新项目建了两个,已经完成的demo项目一个,全部出现;
    报错如下:
    BUNDLE [android, dev] rn_temp/index.js ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ 100.0% (1/1), done.

    error: bundling failed: Error: Unable to resolve module ./components/calendar from /Users/gaoguanxiong/Desktop/test/rnTest/nmi/nmi/node_modules/taro-ui/dist/weapp/index.js: The module ./components/calendar could not be found from /Users/gaoguanxiong/Desktop/test/rnTest/nmi/nmi/node_modules/taro-ui/dist/weapp/index.js. Indeed, none of these files exist:

    • /Users/gaoguanxiong/Desktop/test/rnTest/nmi/nmi/node_modules/taro-ui/dist/weapp/components/calendar(.native||.android.js|.native.js|.js|.android.json|.native.json|.json)
    • /Users/gaoguanxiong/Desktop/test/rnTest/nmi/nmi/node_modules/taro-ui/dist/weapp/components/calendar/index(.native||.android.js|.native.js|.js|.android.json|.native.json|.json)
      at ModuleResolver.resolveDependency (/Users/gaoguanxiong/Desktop/test/rnTest/nmi/nmi/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:161:851)
      at ResolutionRequest.resolveDependency (/Users/gaoguanxiong/Desktop/test/rnTest/nmi/nmi/node_modules/metro/src/node-haste/DependencyGraph/ResolutionRequest.js:91:16)
      at DependencyGraph.resolveDependency (/Users/gaoguanxiong/Desktop/test/rnTest/nmi/nmi/node_modules/metro/src/node-haste/DependencyGraph.js:272:4579)
      at /Users/gaoguanxiong/Desktop/test/rnTest/nmi/nmi/node_modules/metro/src/DeltaBundler/traverseDependencies.js:376:19
      at Array.map (<anonymous>)
      at resolveDependencies (/Users/gaoguanxiong/Desktop/test/rnTest/nmi/nmi/node_modules/metro/src/DeltaBundler/traverseDependencies.js:374:16)
      at /Users/gaoguanxiong/Desktop/test/rnTest/nmi/nmi/node_modules/metro/src/DeltaBundler/traverseDependencies.js:212:33
      at Generator.next (<anonymous>)
      at step (/Users/gaoguanxiong/Desktop/test/rnTest/nmi/nmi/node_modules/metro/src/DeltaBundler/traverseDependencies.js:297:313)
      at /Users/gaoguanxiong/Desktop/test/rnTest/nmi/nmi/node_modules/metro/src/DeltaBundler/traverseDependencies.js:297:473
      DELTA [android, dev] rn_temp/index.js ░░░░░░░░░░░░░░░░ 0.0% (0/1), failed.


  • 与此同时还有一个问题:新建项目的时候,node-sass报错,之后yarn安装node-sass成功,在装taro-ui的时候,如果用npm装的话又会提示已经安装好的node-sass报错,但是yarn就不会提示。。



  • 解决了吗?



  • 官方文档明确说:taro-ui暂不支持RN的
    https://taro-ui.jd.com/#/docs/introduction


登录后回复