React Native 无法解析模块
React Native Unable to resolve module
error: Error: Unable to resolve module react-native-safe-area-context from C:\USER\App\NavigationApp\NavigationApp\node_modules\@react-navigation\stack\src\views\Stack\StackView.tsx: react-native-safe-area-context could not be found within the project.
我什么都没写,就是想学React Navigation。我安装了@react-navigation/native 并认为现在我可以开始了。但是我得到的不是 JSX,而是这个错误:
怎么办?
我的代码:
import React from 'react';
import { View, Text } from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
const App = () => {
return (
<View>
<Text>Hello</Text>
</View>
);
};
const styles = StyleSheet.create({
});
export default App;
react-navigation
包需要几个其他包才能工作,react-native-safe-area-context
是其中的一部分,你只需要安装它
$ npm i --save react-native-safe-area-context
在此处阅读更多内容 (https://reactnavigation.org/docs/getting-started/)
快乐编码
你有没有安装react navigation的依赖? react-native-safe-area-context
是依赖项之一。您还应该安装其他依赖项才能开始工作。为此 运行 如果您使用的是 expo 托管工作流,请执行此命令。
expo install react-native-gesture-handler react-native-reanimated react-native-screens react-native-safe-area-context @react-native-community/masked-view
或者如果您使用的是裸工作流(反应本机 CLI)运行 这个
npm install react-native-reanimated react-native-gesture-handler react-native-screens react-native-safe-area-context @react-native-community/masked-view
另外你应该阅读官方安装doc
error: Error: Unable to resolve module react-native-safe-area-context from C:\USER\App\NavigationApp\NavigationApp\node_modules\@react-navigation\stack\src\views\Stack\StackView.tsx: react-native-safe-area-context could not be found within the project.
我什么都没写,就是想学React Navigation。我安装了@react-navigation/native 并认为现在我可以开始了。但是我得到的不是 JSX,而是这个错误: 怎么办?
我的代码:
import React from 'react';
import { View, Text } from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
const App = () => {
return (
<View>
<Text>Hello</Text>
</View>
);
};
const styles = StyleSheet.create({
});
export default App;
react-navigation
包需要几个其他包才能工作,react-native-safe-area-context
是其中的一部分,你只需要安装它
$ npm i --save react-native-safe-area-context
在此处阅读更多内容 (https://reactnavigation.org/docs/getting-started/) 快乐编码
你有没有安装react navigation的依赖? react-native-safe-area-context
是依赖项之一。您还应该安装其他依赖项才能开始工作。为此 运行 如果您使用的是 expo 托管工作流,请执行此命令。
expo install react-native-gesture-handler react-native-reanimated react-native-screens react-native-safe-area-context @react-native-community/masked-view
或者如果您使用的是裸工作流(反应本机 CLI)运行 这个
npm install react-native-reanimated react-native-gesture-handler react-native-screens react-native-safe-area-context @react-native-community/masked-view
另外你应该阅读官方安装doc