简体   繁体   中英

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

After i convert my project in typescript showing me following error Module '"./node_modules/react-native"' has no exported member '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. Delete your node_modules folder
  2. run this on your terminal npm install @types/react @types/react-native
  3. close the editor and restart everything.

Delete node_modules folder and run npm install or yarn again.

If it not solve this problem, try to run npm install @types/react @types/react-native or yarn add @types/react @types/react-native

Probably you should also use -D option to install it as a development dependency, which adds it to the devDependencies list.

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

or

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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