2

Just created my first React-Native application and added my first library 'react-native-elements' using

yarn add react-native-elements

the package appears in my node_modules folder and yarn.lock, however I receive the following error:

Cannot find module 'react-native-elements'

app.tsx

import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { Button, FormLabel, FormInput, FormValidationMessage } from 'react-native-elements';



export default function App() {
  return (
    <View style={styles.container}>
      <FormLabel>Name</FormLabel>
      <FormInput />
      <FormValidationMessage>Error message</FormValidationMessage>
      <Button>Send</Button>
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
  },
});

Package.json

{
  "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": {
    "expo": "~37.0.3",
    "react": "~16.9.0",
    "react-dom": "~16.9.0",
    "react-native": "https://github.com/expo/react-native/archive/sdk-37.0.1.tar.gz",
    "react-native-elements": "^2.0.2",
    "react-native-screens": "~2.2.0",
    "react-native-web": "~0.11.7"
  },
  "devDependencies": {
    "@babel/core": "^7.8.6",
    "@types/react": "~16.9.23",
    "@types/react-native": "~0.61.17",
    "babel-preset-expo": "~8.1.0",
    "typescript": "~3.8.3"
  },
  "private": true
}
RobC
  • 22,977
  • 20
  • 73
  • 80
wuiiz93
  • 119
  • 1
  • 10

2 Answers2

2

https://react-native-elements.github.io/react-native-elements/docs/troubleshooting.html Can you try this?

yarn - rm -rf node_modules && yarn && yarn add react-native-elements
npm start -- --reset-cache
Anhdevit
  • 1,926
  • 2
  • 16
  • 29
  • Thanks for that I encountered a warning: warning " > react-native-elements@2.0.2" has unmet peer dependency "react-native-vector-icons@>6.6.0". – wuiiz93 Jun 05 '20 at 06:59
  • Because you don't have install react-native-vector-icon follow document above and install it using yarn add react-native-vector-icons and cd ios pod install – Anhdevit Jun 05 '20 at 07:14
0

Given that previous answer did not help me, here is what I finally found to solve it:

Source of problem:

yarn add react-native-elements

Solution (that worked with me):

yarn add @types/react-native-elements