Md Hasim
Md Hasim

Reputation: 1

Error: While trying to resolve module `@react-navigation/stack` from file `C:\Users\moham\MobileApp\App.tsx`,

import React from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
import Welcome from './src/welcome/welcomescreen' 
import Login from './src/login/loginscreen'; 
const Stack = createStackNavigator();
export default function App() {
  return (
    <NavigationContainer>
      <Stack.Navigator options={{ headerShown: false }}  initialRouteName="Welcome"> 
        <Stack.Screen name="Welcome" component={Welcome} /> 
        <Stack.Screen name="Login" component={Login} />
      </Stack.Navigator>
    </NavigationContainer>
  );
}

hey my react native version is 0.75.4. the above is my app.jsx code. here i'm trying to navigate from welcome screen to login screen. for that im using NavigationContainer and createStackNavigator packages. but in vain i got the below error

error: Error: While trying to resolve module `@react-navigation/stack` from file `C:\Users\moham\MobileApp\App.tsx`, the package `C:\Users\moham\MobileApp\node_modules\@react-navigation\stack\package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved (`C:\Users\moham\MobileApp\node_modules\@react-navigation\stack\src\index.tsx`. Indeed, none of these files exist:

  * C:\Users\moham\MobileApp\node_modules\@react-navigation\stack\src\index.tsx(.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)
  * C:\Users\moham\MobileApp\node_modules\@react-navigation\stack\src\index.tsx\index(.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)
    at DependencyGraph.resolveDependency (C:\Users\moham\MobileApp\node_modules\metro\src\node-haste\DependencyGraph.js:244:17)
    at C:\Users\moham\MobileApp\node_modules\metro\src\lib\transformHelpers.js:156:21
    at resolveDependencies (C:\Users\moham\MobileApp\node_modules\metro\src\DeltaBundler\buildSubgraph.js:42:25)
    at visit (C:\Users\moham\MobileApp\node_modules\metro\src\DeltaBundler\buildSubgraph.js:83:30)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Promise.all (index 0)
    at async buildSubgraph (C:\Users\moham\MobileApp\node_modules\metro\src\DeltaBundler\buildSubgraph.js:103:3)
    at async Graph._buildDelta (C:\Users\moham\MobileApp\node_modules\metro\src\DeltaBundler\Graph.js:157:22)
    at async Graph.traverseDependencies (C:\Users\moham\MobileApp\node_modules\metro\src\DeltaBundler\Graph.js:49:19)
    at async DeltaCalculator._getChangedDependencies (C:\Users\moham\MobileApp\node_modules\metro\src\DeltaBundler\DeltaCalculator.js:187:42)

i want to navigate from welcome screen to login screen where. there is a problem with packages that i use, i think. could you please let me know what is the solution for this error or is there is any other alternative packages?

Upvotes: 0

Views: 37

Answers (0)

Related Questions