wuiiz93
wuiiz93

Reputation: 131

Cannot find module 'react-native-elements'

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
}

Upvotes: 3

Views: 6101

Answers (2)

Szymon Stryczek
Szymon Stryczek

Reputation: 21

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

Upvotes: 1

Anhdevit
Anhdevit

Reputation: 2104

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

Upvotes: 4

Related Questions