繁体   English   中英

模块 '"./node_modules/react-native"' 没有导出的成员 'View'

[英]Module '"./node_modules/react-native"' has no exported member 'View'

在我在 typescript 中转换我的项目后,向我显示以下错误模块 '"./node_modules/react-native"' 没有导出的成员 'View'。

import React from 'react';
import {StyleSheet,View,Text} from 'react-native';

export default function App() {
return (
  <View style={{ flex: 1 }}>
    <Text>Welcome</Text>
  </View>
 );
}
  1. 删除你的node_modules文件夹
  2. 在你的终端上运行这个npm install @types/react @types/react-native
  3. 关闭编辑器并重新启动一切。

删除node_modules文件夹并再次运行npm installyarn

如果不能解决这个问题,尝试运行npm install @types/react @types/react-nativeyarn add @types/react @types/react-native

可能您还应该使用 -D 选项将其安装为开发依赖项,这会将其添加到 devDependencies 列表中。

npm install --save-dev @types/react @types/react-native
(npm install -D @types/react @types/react-native)

或者

yarn add --dev @types/react @types/react-native
(yarn add -D @types/react @types/react-native)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM