2023-02-10 Requiring module "node_modules\react-native-reanimated\src\index.ts",(未解决)
完整报错:
Error: Requiring module "node_modules\react-native-reanimated\src\index.ts", which threw an exception: TypeError: ReanimatedModule.installTurboModule is not a function. (In 'ReanimatedModule.installTurboModule()', 'ReanimatedModule.installTurboModule' is undefined)
ERROR Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication). A frequent cause of the error is that the application entry file path is incorrect.
This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.
ERROR Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication). A frequent cause of the error is that the application entry file path is incorrect.
This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.
ok,我只关注了第一句话:Requiring module "node_modules\react-native-reanimated\src\index.ts"(需要模块“node_modules\react native reanimated\src\index.ts”)
报错回溯:我的目的是使用插件react-native-tab-view来制作一个tab选项卡,把react-native-tab-view、react-native-reanimated和react-native-gesture-handler都装了后,按照官网代码进行使用报错。
我做了一下操作:
删除node_module,在android(注意我只在安卓机测试)里找到gradle.properties并在里面添加:
newArchEnabled=true
在babel.config.js里面添加react-native-reanimated/plugin
module.exports = { presets: ['module:metro-react-native-babel-preset'], plugins: ["react-native-reanimated/plugin"], };
把react-native-reanimated版本(2.14.2)修改为2.4.0
找到android/app/build.gradle,把project.ext.react的enableHermes的false改成true,
project.ext.react = [ enableHermes: true, // clean and rebuild if changing ]
在项目入口文件index.js的第一行写上
import 'react-native-gesture-handler';
然并卵,已经放弃了react-native-tab-view的使用。

浙公网安备 33010602011771号