简体   繁体   中英

NPM not recognising my module (requiring unknown module)

I'm working an a React-Native app, and am writing my components into different files, exporting them and importing them wherever they're needed. This is working fine in all instances instead of one, where npm keeps throwing a ' Requiring unknown module '-error.

My structure is as follows:

  • navigator
    • Navigator.js
    • NavBar.js

In NavBar.js , I am exporting my component like so:

class NavBar extends Component {  
    ...
}
export default NavBar;

And importing it in Navigator.js like so:

import NavBar from './NavBar';

The complete message I get on my device when trying to run the app is as follows:
Requiring unknown module "./NavBar". If you are sure the module is there, try restarting the packager or running "npm install".

I have tried both those things (multiple times) to no avail.
I must be looking over something stupid, but can't seem to find it. Can anyone else see what I'm doing wrong here?

What I did to get it fixed:
I refactored the file to something else, and back to NavBar.js .

This was probably just caused by me misspelling something in the first place.
So don't forget to check, double check and double check again.

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-2024 STACKOOM.COM