24jieqi / react-native-xiaoshu

🌈 React Native UI library
https://24jieqi.github.io/react-native-xiaoshu
Apache License 2.0
187 stars 21 forks source link

Expo 中引入时报错 Invariant Violation: Module AppRegistry is not a registered callable module #41

Closed lblblong closed 7 months ago

lblblong commented 7 months ago

报错 Invariant Violation: Module AppRegistry is not a registered callable module

 expo-env-info 1.0.5 environment info:
    System:
      OS: macOS 14.1.1
      Shell: 3.2.57 - /bin/sh
    Binaries:
      Node: 21.1.0 - /opt/homebrew/bin/node
      Yarn: 1.22.21 - /opt/homebrew/bin/yarn
      npm: 10.2.0 - /opt/homebrew/bin/npm
    SDKs:
      iOS SDK:
        Platforms: DriverKit 23.0, iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0
    IDEs:
      Android Studio: 2022.3 AI-223.8836.35.2231.11005911
      Xcode: 15.0.1/15A507 - /usr/bin/xcodebuild
    npmPackages:
      expo: ~49.0.15 => 49.0.19 
      react: 18.2.0 => 18.2.0 
      react-native: 0.72.6 => 0.72.6 
    Expo Workflow: managed
onlyling commented 7 months ago

可能是一些 peerDependencies 没有安装。

yarn add rc-field-form react-native-safe-area-context react-native-svg

复现这个问题的时候发现采用 npm 管理依赖会出现一些奇怪的问题(@fruits-chain/react-native-xiaoshu 目录下的 node_modules 里面存在不同版本的 react-native,导入 @fruits-chain/react-native-xiaoshu 就会红屏报错),推荐使用 yarn

image image
lblblong commented 7 months ago

确实换成 yarn 就可以了 👍