Morton
Morton

Reputation: 5760

Unable to resolve module by using native-base

I take a reference from https://docs.nativebase.io/ , when i try to use the sample code it shows the error Unable to resolve module , it just like the photo enter image description here My environment is:

"expo": "^18.0.4",
"native-base": "^2.2.1",
"react": "16.0.0-alpha.12",
"react-native": "https://github.com/expo/react-native/archive/sdk-18.0.1.tar.gz",

Here is my App.js:

import React from 'react';
// import { StyleSheet, View, Text } from 'react-native';
import { Container, Button, Text } from 'native-base';

export default class App extends React.Component {

  render() {
    return (
      <Container>
        <Button>
          <Text>
            Button
          </Text>
        </Button>
      </Container>
    );
  }
}

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

I find that i just import 'native-base' cause the error import { Container, Button, Text } from 'native-base';

Please tell me what step i miss it . Thanks in advance.

Upvotes: 3

Views: 12328

Answers (1)

Jeffrey
Jeffrey

Reputation: 4650

I think you have forgot to install the native-base component first, if not then use the following command inside your project

npm install native-base --save

Upvotes: 9

Related Questions