'@reactnavigation/drawer 和@reactnavigation/native 没有在我的 React 本机代码中解析。我应该怎么办?
'@reactnavigation/drawer and @reactnavigation/native aren't being resolved in my react native code. What should I do?
我正在尝试使用 React Native 制作一个应用程序。但是,问题是抽屉模块和本机模块没有被解析,或者“找不到模块:无法解析'@reactnavigation/drawer'”和“找不到模块:无法解析'@ reactnavigation/native'".
我能想到的步骤我都做了。我有 node.js,安装了 expo-cli,运行 expo init,cd 到项目名称,并安装了 npm install @react-navigation/stack", "npm install @react-navigation/native", “npm install @react-navigation/drawer”、“expo install react-native-gesture-handler react-native-reanimated”,甚至在某人的推荐下添加了“npm install react-native-reanimated@~2.2.0”否则。
但即使我认为我正在按照每一步进行,它仍然不是 working.The 我能想到的唯一另一个问题是节点版本。但是当我使用“删除程序”卸载它并重新安装它时,在推荐的版本中,它停留在较早下载的版本。但我什至不确定这是问题所在。我该怎么办?
import * as React from 'react';
import { View, Text } from 'react-native';
import { NavigationContainer } from '@reactnavigation/native';
import { createDrawerNavigator } from '@reactnavigation/drawer';
function Home() {
return (
<View style={{ flex: 1, justifyContent: 'center',
alignItems: 'center' }}>
<Text>Home</Text></View>);}
function AboutUs() {
return (
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<Text>About Us</Text>
</View>
);}
const Drawer = createDrawerNavigator();
函数 MyDrawer() {
return (
);}
导出默认函数 App() {
return (
);}
{
"name": "drawernav",
"version": "1.0.0",
"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/drawer": "^6.4.1",
"@react-navigation/native": "^6.0.10",
"@react-navigation/stack": "^6.2.1",
"expo": "~44.0.0",
"expo-status-bar": "~1.2.0",
"react": "17.0.1",
"react-dom": "17.0.1",
"react-native": "0.64.3",
"react-native-gesture-handler": "~2.1.0",
"react-native-reanimated": "~2.3.1",
"react-native-web": "0.17.1",
"react-navigation-stack": "^2.10.4"
},
"devDependencies": {
"@babel/core": "^7.12.9"
},
"private": true
}
你的输入有误,应该是
import {NavigationContainer} from '@react-navigation/native';
import {createDrawerNavigator} from '@react-navigation/drawer';
我正在尝试使用 React Native 制作一个应用程序。但是,问题是抽屉模块和本机模块没有被解析,或者“找不到模块:无法解析'@reactnavigation/drawer'”和“找不到模块:无法解析'@ reactnavigation/native'".
我能想到的步骤我都做了。我有 node.js,安装了 expo-cli,运行 expo init,cd 到项目名称,并安装了 npm install @react-navigation/stack", "npm install @react-navigation/native", “npm install @react-navigation/drawer”、“expo install react-native-gesture-handler react-native-reanimated”,甚至在某人的推荐下添加了“npm install react-native-reanimated@~2.2.0”否则。
但即使我认为我正在按照每一步进行,它仍然不是 working.The 我能想到的唯一另一个问题是节点版本。但是当我使用“删除程序”卸载它并重新安装它时,在推荐的版本中,它停留在较早下载的版本。但我什至不确定这是问题所在。我该怎么办?
import * as React from 'react';
import { View, Text } from 'react-native';
import { NavigationContainer } from '@reactnavigation/native';
import { createDrawerNavigator } from '@reactnavigation/drawer';
function Home() {
return (
<View style={{ flex: 1, justifyContent: 'center',
alignItems: 'center' }}>
<Text>Home</Text></View>);}
function AboutUs() {
return (
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<Text>About Us</Text>
</View>
);}
const Drawer = createDrawerNavigator();
函数 MyDrawer() {
return (
{
"name": "drawernav",
"version": "1.0.0",
"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/drawer": "^6.4.1",
"@react-navigation/native": "^6.0.10",
"@react-navigation/stack": "^6.2.1",
"expo": "~44.0.0",
"expo-status-bar": "~1.2.0",
"react": "17.0.1",
"react-dom": "17.0.1",
"react-native": "0.64.3",
"react-native-gesture-handler": "~2.1.0",
"react-native-reanimated": "~2.3.1",
"react-native-web": "0.17.1",
"react-navigation-stack": "^2.10.4"
},
"devDependencies": {
"@babel/core": "^7.12.9"
},
"private": true
}
你的输入有误,应该是
import {NavigationContainer} from '@react-navigation/native';
import {createDrawerNavigator} from '@react-navigation/drawer';