0

React native App I use nx monorepo but when I run my app I have this problem :

Unable to resolve module ./createAppContainer from /Users/X/X/node_modules/@react-navigation/native/lib/commonjs/index.js

I have already installed @react-navigation/native ...

Thanks

import React from 'react'
import { Provider } from 'react-native-paper'
import { NavigationContainer } from '@react-navigation/native'
import { createStackNavigator } from '@react-navigation/stack'
import { theme } from './src/core/theme'
import {
  AuthLoadingScreen,
  StartScreen,
  LoginScreen,
  RegisterScreen,
  ResetPasswordScreen,
  Dashboard,
} from './src/screens'

const Stack = createStackNavigator()

export default function App() {
  return (
    <Provider theme={theme}>
      <NavigationContainer>
        <Stack.Navigator
          initialRouteName="AuthLoadingScreen"
          screenOptions={{
            headerShown: false,
          }}
        >
          <Stack.Screen
            name="AuthLoadingScreen"
            component={AuthLoadingScreen}
          />
          <Stack.Screen name="StartScreen" component={StartScreen} />
          <Stack.Screen name="LoginScreen" component={LoginScreen} />
          <Stack.Screen name="RegisterScreen" component={RegisterScreen} />
          <Stack.Screen name="Dashboard" component={Dashboard} />
          <Stack.Screen
            name="ResetPasswordScreen"
            component={ResetPasswordScreen}
          />
        </Stack.Navigator>
      </NavigationContainer>
    </Provider>
  )
}

1 Answers1

0

How did you install the packages? npm or yarn? Also it is important to look at the documentation of the react-navigation lib, it gives specific instructions on how to install the package.

Here is the link, just have a look at it and see if you did something wrong, react-navigation-docs.

Fehr Faber
  • 35
  • 6
  • Thanks for your answer. Now I have this error :( error: Error: While trying to resolve module `nanoid/non-secure` from file `/Users/X/X/X/node_modules/@react-navigation/routers/lib/commonjs/BaseRouter.js`, the package `/Users/X/X/X/node_modules/nanoid/non-secure/package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved (`/Users/X/X/X/node_modules/nanoid/non-secure/index.cjs`. Indeed, none of these files exist – underscoreA Aug 04 '22 at 08:42
  • [Post](https://stackoverflow.com/questions/60124435/however-this-package-itself-specifies-a-main-module-field-that-could-not-be-r) I hope this link helps to resolve your problem, check the solution for the post. – Fehr Faber Aug 04 '22 at 20:40
  • Thanks. I solved the problem by adding cjs in sourceExts in metro.config.js file. resolver: { ..... sourceExts: [...sourceExts, 'svg', 'cjs'], .... }, – underscoreA Aug 10 '22 at 08:41