I run the project yesterday and it works very well. Today, when I run my RN project with react-native run-ios and I got module could not be found suddenly.
My project's React-native versions
react-native-cli: 2.0.1
react-native: 0.52.2
My project's watchman version
4.9.0
My Folder Structure
src
components
screens
stores
Config.js
The following is my Config.js
const host = "localhost:5000";
const proto = "http://";
const api = "/api";
const Config = {
urls: {
signin_start: proto + host + api + "/signin/start",
signin_verify: proto + host + api + "/signin/verify",
}
};
export default Config;
I use Config from screens/signInStart.js file like the following
import Config from "../Config";
And I got an error like the following
The module `../Config` could not be found
How can I fix? I already do clear react native cache by running the following command. But, still can't fix.
watchman watch-del-all && rm -rf $TMPDIR/react-* && rm -rf node_modules/ && npm cache clean && npm install && npm start -- --reset-cache
After looking and debugging for a very long time, I finally solved my problem by one of react native Github issue.
rm -rf node_modules && npm installrm -fr $TMPDIR/react-*watchman watch-del-allhttps://github.com/facebook/react-native/issues/4968
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With