简体   繁体   中英

React-native unable to resolve module on importing a js file

I am getting this error whenever I try to import a new js page. I am fairly new to react-native so this might be an easy error to fix or it might be a bug on their side at the moment, I am not sure. This is my import line -> import Home from 'Home'; Both files are in the same directory. The error I get is it says

unable to resolve module 'Home' from 'path/App.js' : Module does not exist in the module map'.

Now what confuses me is that the path on the error is App.js when I am trying to specify a file called Home.js.

You probably want to use a relative import like this:

import Home from './Home';

Of course, that is assuming the Home component is in the same level as your App component and that you exported it as the default export:

export default Home

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2025 STACKOOM.COM