无法在反应本机中解析模块

Unable to Resolve module in react-native

问题:
每当我尝试导入 .js 或任何图像文件时,我都会得到这个

Unable to resolve module Error

我已检查文件路径是否正确。

路径:

App.js :

import React, { Component } from "react";
import {
  Container,
  Header,
  Button,
  Icon,
  Item,
  Input,
  Content,
  Footer,
  FooterTab,
  Text,
  Tabs,
  Tab,
  TabHeading,
  Right,
  Left,
  Body,
  Thumbnail,
  StyleProvider
  } from "native-base";
import { Font } from 'expo';

import getTheme from './native-base-theme/components';
import commonColor from './native-base-theme/variables/commonColor';
export default class AnatomyExample extends Component {

  render() {
    return (
      <StyleProvider style={getTheme(commonColor)}>
      <Container>
        <Header 
           style={{ backgroundColor: "#FFF" }} 
          androidStatusBarColor="#fff">
         <Left>
            <Button>
            <Icon active name="menu" style={{ color: "#5d61cc" }}/>
            </Button>
          </Left>
          <Body>
            <Text style={{fontSize: 20, fontWeight: 'bold'}}>Home</Text>
          </Body>
          <Right />
        </Header>
        <Tabs   tabBarBackgroundColor='white'  style={{ elevation: 3 }} >
        <Tab heading={<TabHeading ><Icon name="home" style={{color: "#5d61cc"}}/></TabHeading>} >
           </Tab>

           <Tab  heading={<TabHeading><Icon name="search" style={{color: "#5d61cc"}}/></TabHeading>}>
           </Tab>

          <Tab  heading={<TabHeading><Icon ios='ios-notifications'  android='md-notifications'
           style={{ color: "#5d61cc"}}/></TabHeading>}>
           </Tab>

           <Tab  heading={<TabHeading><Icon name="mail" style={{ color: "#5d61cc"}}/></TabHeading>}>
           </Tab>

        </Tabs>
        <Content padder />

        <Footer style={{backgroundColor: 'white'}}>
        <FooterTab style={{backgroundColor: 'white'}}>
          <Button >
            <Text style={{fontSize: 12, color: "#5d61cc", fontWeight: 'bold'}}>All</Text>
          </Button>
          <Button>
            <Text style={{  fontWeight: 'bold'}}>Mentions</Text>
          </Button>

        </FooterTab>
        <Right>
            <Icon style={{ marginRight: 10, color: "#5d61cc" }} name='settings'></Icon>
        </Right>
      </Footer>

      </Container>
    </StyleProvider>
    );
  }
}

function newFunction() {
  return '';
}

错误:

Unable to resolve ./native-base-theme/components" from "./C:\Users\Abc\AwesomeProject\App.js" could not resolve C:\Users\Abc\AwesomeProject\native-base-theme\components' as a file nor as a folder","name":"UnableToResolveError","type":"UnableToResolveError","errors":[{}]},"type":"bundling_error"}"

如果您想使用这种方式导入 getTheme./native-base-theme/components 您必须将索引文件放在 components 文件夹中。

否则,您可以直接从定义getTheme函数的文件导入。

import getTheme from './native-base-theme/components/somefile';

import { getTheme } from './native-base-theme/components/somefile';

取决于您如何在该文件中定义 getTheme