Android react导航安装和首次使用
我使用了react native,版本是Android react导航安装和首次使用,android,reactjs,react-native,react-navigation,Android,Reactjs,React Native,React Navigation,我使用了react native,版本是“version”:“0.57.1”。我已通过以下方式安装react导航: npm install --save react-navigation react导航版本为react-navigation@3.4.0。app.js文件内容如下: import * as React from 'react'; import { Text, View } from 'react-native'; // import { createStackNavigator
“version”:“0.57.1”
。我已通过以下方式安装react导航:
npm install --save react-navigation
react导航版本为react-navigation@3.4.0
。app.js文件内容如下:
import * as React from 'react';
import { Text, View } from 'react-native';
// import { createStackNavigator } from 'react-navigation';
class HomeScreen extends React.Component {
render() {
return (
<View style={{ flex: 1, alignItems: "center", justifyContent: "center" }}>
<Text>Home Screen</Text>
</View>
);
}
}
export default HomeScreen;
import*as React from'React';
从“react native”导入{Text,View};
//从“反应导航”导入{createStackNavigator};
类主屏幕扩展了React.Component{
render(){
返回(
主屏幕
);
}
}
导出默认主屏幕;
此示例在expo上运行良好。但当我运行第三行时,出现了一个错误
[16:57:50]尝试从文件解析模块反应导航时
/home/ubuntu/workspace/App.js
,软件包
/home/ubuntu/workspace/node\u modules/react导航/package.json
已成功找到。但是,这个包本身指定了一个
main
无法解析的模块字段
(/home/ubuntu/workspace/node_modules/react-navigation/src/react-navigation.js
)。
事实上,这些文件都不存在:[16:57:50][16:57:50]*
/home/ubuntu/workspace/node|u modules/react navigation/src/react navigation.js(.native | android.js |.native.json |.native.json |.android.ts |.ts |.android.tsx |.native.tsx |.tsx)
[16:57:50] *
/home/ubuntu/workspace/node_modules/react navigation/src/react navigation.js/index(.native | android.js |.native.js |.android.json |.native.json |.android.ts |.ts |.android.tsx |.native.tsx |.tsx)
这很奇怪,您不需要安装react navigation,特别是在制作世博会项目时,它应该自动安装。我建议删除您的节点模块,然后按照以下步骤重新安装
rm -rf node_module && npm install
npm audit fix
expo start
如果这不起作用,请尝试创建一个新项目,并将您的类复制到该项目中,希望这有帮助这很奇怪,您不需要安装react navigation,特别是在创建expo项目时,它应该自动安装。我建议删除您的节点模块,然后使用以下命令重新安装
rm -rf node_module && npm install
npm audit fix
expo start
如果这不起作用,试着做一个新项目,把你的课程复制到项目中,希望这能有所帮助。指南把我弄糊涂了:/指南把我弄糊涂了:/