Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native the module could not be found

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
like image 558
Set Kyar Wa Lar Avatar asked Jun 03 '26 06:06

Set Kyar Wa Lar


1 Answers

After 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.com/facebook/react-native/issues/4968

like image 151
Set Kyar Wa Lar Avatar answered Jun 05 '26 01:06

Set Kyar Wa Lar