React Native index.js无法解析模块'/src/App.js

时间:2018-05-14 13:26:22

标签: node.js react-native

我已经成功运行了模拟器一段时间了,但是,index.js文件似乎无法解析src文件夹中App.js文件的路径。

我在ESLint上收到以下错误:无法解析模块'./src/App'的路径。 (进口/无未解决)

我在ios和android模拟器中收到以下错误: 无法加载包(http://localhost:8081/index.bundle? platform = ios& dev = true& minify = false),但有错误:(无法从./src/App解析模块Users/williamgoodhew/projects/athalens/apps/index.js:无法从./src/App找到模块./Users/williamgoodhew/projects/athalens/apps/index.js。实际上,这些文件都不存在:

* /Users/williamgoodhew/projects/athalens/apps/src/App(.native||.ios.js|.native.js|.js|.ios.json|.native.json|.json) * /Users/williamgoodhew/projects/athalens/apps/src/App/index(.native||.ios.js|.native.js|.js|.ios.json|.native.json|.json)(null))

this is the directory structure

这是index.js文件

import { AppRegistry } from 'react-native';
import App from './src/App';

console.ignoredYellowBox = [
    'Setting a timer'
];

AppRegistry.registerComponent('apps', () => App);

这是App.js文件

import React, { Component } from 'react';
import { Provider } from 'react-redux';
import { createStore, applyMiddleware } from 'redux';
import firebase from 'firebase';
import ReduxThunk from 'redux-thunk';
import reducers from './reducers';
import Router from './Router';

class App extends Component {
  componentDidMount() {
    const config = {
      apiKey: '...........................',
      authDomain: '..........firebaseapp.com',
      databaseURL: 'https://...............firebaseio.com',
      projectId: '...........',
      storageBucket: '..............appspot.com',
      messagingSenderId: '.................'
    };

    firebase.initializeApp(config);
  }

  render() {
    const store = createStore(reducers, {}, applyMiddleware(ReduxThunk));

    return (
      <Provider store={store}>
        <Router />
      </Provider>
    );
  }
}

export default App;

0 个答案:

没有答案