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
ponents
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 mand. 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
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
ponents
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 mand. 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
Share
Improve this question
asked Mar 24, 2018 at 7:11
Set Kyar Wa LarSet Kyar Wa Lar
4,6446 gold badges33 silver badges57 bronze badges
1
- have You tried "npm run ios" script: "ios": "node node_modules/react-native/local-cli/cli.js run-ios" ? – John Tribe Commented Jul 14, 2019 at 16:15
1 Answer
Reset to default 2After looking and debugging for a very long time, I finally solved my problem by one of react native Github issue.
- Delete the node_modules folder:
rm -rf node_modules && npm install
- Reset packager cache:
rm -fr $TMPDIR/react-*
- Clear watchman watches:
watchman watch-del-all
- Recreate the project from scratch
https://github./facebook/react-native/issues/4968