将导航容器和导航器添加到 nx monorepo React Native 项目即使在安装了 ReactNative 手势处理程序后也会出现此错误:
不变违规:TurboModuleRegistry.getEnforcing(...):找不到“RNGestureHandlerModule”。验证此名称的模块是否已在本机二进制文件中注册。
import React from 'react';
import { StyleSheet, SafeAreaView } from 'react-native';
import { theme } from '@NxDemo/theme';
import { HomeScreen, Profile } from '@NxDemo/ui-components';
import { AppNavigationContainer, TabNavigator } from '@NxDemo/navigation';
const App = () => {
return (
<SafeAreaView style={styles.container}>
<AppNavigationContainer>
<TabNavigator
screens={[
{ name: 'Home', component: HomeScreen },
{ name: 'Profile', component: Profile },
]}
initialRouteName="Home"
/>
</AppNavigationContainer>
</SafeAreaView>
);
};
export default App;
这是我的metro.config.js 文件
const { withNxMetro } = require('@nx/react-native');
const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');
const defaultConfig = getDefaultConfig(__dirname);
const { assetExts, sourceExts } = defaultConfig.resolver;
/**
* Metro configuration
* https://reactnative.dev/docs/metro
*
* @type {import('metro-config').MetroConfig}
*/
const customConfig = {
transformer: {
babelTransformerPath: require.resolve('react-native-svg-transformer'),
},
resolver: {
assetExts: assetExts.filter((ext) => ext !== 'svg'),
sourceExts: [...sourceExts, 'cjs', 'mjs', 'svg'],
},
};
module.exports = withNxMetro(mergeConfig(defaultConfig, customConfig), {
// Change this to true to see debugging info.
// Useful if you have issues resolving modules
debug: false,
// all the file extensions used for imports other than 'ts', 'tsx', 'js', 'jsx', 'json'
extensions: [],
// Specify folders to watch, in addition to Nx defaults (workspace libraries and node_modules)
watchFolders: [],
});
我想将选项卡导航添加到 nx monorepo React Native 项目,并且出现此错误: Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'RNGestureHandlerModule' 无法找到。验证此名称的模块是否已在本机二进制文件中注册。
我已经有了 "react-native-gesture-handler": "^2.16.2",package.json 中的这个依赖项
同样的问题。我尝试降级但没有任何结果。