React Navigationでエラーが出た
React Native Expoでアプリ開発
Udemyで学習中です
標記の件で少しつまずいたので書きました
下記のようなエラーが出ました
Unable to resolve module @react-navigation/native-stack
@react-navigation/native-stack could not be found within the project or in these directories:
node_modules
If you are sure the module exists, try these steps:
1. Clear watchman watches: watchman watch-del-all
2. Delete node_modules and run yarn install
3. Reset Metro's cache: yarn start --reset-cache
4. Remove the cache: rm -rf /tmp/metro-*
↓こういうのも試したけどダメだった
$ watchman del-all
$ rm -rf node_modules && yarn install
$ yarn cache clean
$ rm -rf /tmp/metro-*
動画の解説はバージョン5だったのだけど、僕は6でやってた
コードは同じだと思ったのだけど、よく見たら違ってた
それを直したらうまくいった
Version: 6.x
import { NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
const Stack = createNativeStackNavigator();
Version: 5.x
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
const Stack = createStackNavigator();
バージョンには気をつけますのだ
この記事が気に入ったらサポートをしてみませんか?