反应导航安装和首次使用

问题描述 投票:1回答:1

我使用react-native,版本是"version": "0.57.1"。我已通过以下方式安装了react-navigation:

npm install --save react-navigation

反应导航版本是[email protected]。 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;

此示例在世博会上正常运行。但是当我运行第三行时,会发生错误。

[16:57:50]在尝试从文件react-navigation解析模块/home/ubuntu/workspace/App.js时,成功找到了包/home/ubuntu/workspace/node_modules/react-navigation/package.json。但是,这个包本身指定了一个无法解析的main模块字段(/home/ubuntu/workspace/node_modules/react-navigation/src/react-navigation.js。确实,这些文件都不存在:[16:57:50] [16:57:50] * /home/ubuntu/workspace/node_modules/react-navigation/src/react-navigation.js(.native||.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.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|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)

enter image description here

android reactjs react-native react-navigation
1个回答
0
投票

这很奇怪你不应该特别安装反应导航这应该在制作一个expo项目时自动安装我建议删除你的节点模块并再次安装以下

rm -rf node_module && npm install
npm audit fix 
expo start

如果这不成功,请尝试制作一个新项目,然后将您的课程复制到它希望这会有所帮助

© www.soinside.com 2019 - 2024. All rights reserved.