2017-05-11 2 views
2

저는 일하기 위해 노력하고있는 매우 간단한 React Native 프로젝트가 있습니다. UIViewController에 RCTRootView를 단순히 추가하는 iOS 프로젝트입니다. 나는 웹 브라우저에서 URL을 칠 때 나는 얻을 :React Native : 모듈을 해결할 수 없습니다.

Unable to resolve module `/src/components/HelloReact` from `/Users/myusername/Desktop/DemoReact/index.ios.js`: Directory /src/components/HelloReact doesn't exist. 

index.ios.js

'use strict'; 

import { AppRegistry } from 'react-native'; 
import HelloReact from '/src/components/HelloReact'; 

AppRegistry.registerComponent('HelloReact',() => HelloReact); 

HelloReact.js

import React, { Component } from 'react'; 
import { AppRegistry, Text } from 'react-native'; 

export default class HelloReact extends Component { 
    render() { 
    return (
     <Text style={{fontWeight: 'bold'}}> 
     I am bold 
     <Text style={{color: 'red'}}> 
      and red 
     </Text> 
     </Text> 
    ) 
    } 
} 

나는 딱하다 이 문제를 해결하는 방법. 나는 다음의 모든 시도 :

  • npm start
  • npm start --reset-cache
  • 삭제 된 node_modules 디렉토리 및
  • 제거 된을 다시 설치하고 노드가 경비원은, 반응 네이티브 다시 설치하고, NPM
  • 는 물리적 장치에 시도 및 시뮬레이터

누구든지 내 코드에서 잘못되거나 아는 것이 있습니까? 무슨 문제일까요? 나는 이것을 해결하기 위해 이메일이나 전화를 통해 대화 할 의향이 있습니다. 나는 필사적이다. 절대 경로에서 모듈에 대한

답변

5

import HelloReact from '/src/components/HelloReact'; 검색 (RN 응용 프로그램) 디렉토리와 현재를 기준으로하지 때문에 (그렇지 않은 존재하는 않는 한) import HelloReact from './src/components/HelloReact';

+0

와우에

변경이 그것을 찾을 수 없습니다 RN! 나는 바보이다. 그게 효과가 있었어! 정말 고마워! 앱을 실행할 때 여전히 다른 문제가 있지만이 질문을 수정하고 새 질문을 다시 게시 해 보겠습니다. – tentmaking

+0

Gald to help;) 도움이된다면 답변으로 표시하십시오.^_^ –

+0

나는 그것을 가능한 한 빨리 답변으로 표시 할 것입니다! 정말 고맙습니다. 다음 질문입니다! – tentmaking

관련 문제