gpt4 book ai didi

react-native - 无法解析模块@react-navigation/stack

转载 作者:行者123 更新时间:2023-12-05 09:05:30 25 4
gpt4 key购买 nike

我创建了一个空白项目 whit expo init 然后我安装了 react-navigation whit npm install @react-navigation/nativeexpo install react-native-gesture-handler react-native- reanimated react-native-screens react-native-safe-area-context @react-native-community/masked-view 但是当我运行应用程序时 expo start 我得到这个错误:无法从 C:\Android\test\App.js 解析模块@react-navigation/stack:在项目中找不到@react-navigation/stack。

错误截图: enter image description here

App.js 文件:

import * as React from 'react';
import { View, Text } from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';

function HomeScreen() {
return (
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<Text>Home Screen</Text>
</View>
);
}

const Stack = createStackNavigator();

function App() {
return (
<NavigationContainer>
<Stack.Navigator>
<Stack.Screen name="Home" component={HomeScreen} />
</Stack.Navigator>
</NavigationContainer>
);
}

export default App;

我用来安装 react-navigation 的链接

我用来创建 App.js 的链接 here

package.json 文件:

{
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
"eject": "expo eject"
},
"dependencies": {
"@react-navigation/native": "^5.9.4",
"expo": "~41.0.0",
"expo-status-bar": "~1.0.4",
"react": "16.13.1",
"react-dom": "16.13.1",
"react-native": "https://github.com/expo/react-native/archive/sdk-41.0.0.tar.gz",
"react-native-web": "~0.13.12",
"react-native-gesture-handler": "~1.10.2",
"react-native-reanimated": "~2.1.0",
"react-native-screens": "~3.0.0",
"react-native-safe-area-context": "3.2.0",
"@react-native-community/masked-view": "0.1.10"
},
"devDependencies": {
"@babel/core": "^7.9.0"
},
"private": true
}

节点版本:v14.16.1

Npm 版本:6.14.12

最佳答案

按照错误所说的去做,

在终端npm 安装@react-navigation/stack或者 yarn 添加@react-navigation/stack

关于react-native - 无法解析模块@react-navigation/stack,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67173318/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com