React Native执行react-native run-ios突发模块找不到问题求助
Hey there, sorry to hear you're hitting this "module could not be found" error out of nowhere—especially since everything worked perfectly yesterday! Let's walk through some tried-and-true fixes that usually resolve this kind of issue with React Native 0.52.2.
Stale cache is almost always the culprit for sudden module errors. Run these commands in your project root one by one:
watchman watch-del-allrm -rf node_modules && npm installrm -rf $TMPDIR/react-*rm -rf ios/build- Finally, re-run:
react-native run-ios
Config.js Since Config.js lives in your project root, make sure every file importing it uses the correct relative path. For example, if you're importing from a file in src/screens, the path should look like:
import Config from '../../Config';
If you prefer absolute paths, you can set up a resolver in your .babelrc (you'll need to install babel-plugin-module-resolver first with npm install --save-dev babel-plugin-module-resolver):
{ "plugins": [ ["module-resolver", { "root": ["./"] }] ] }
Your watchman version (4.9.0) is compatible with RN 0.52.2, but it can sometimes get stuck. After running watchman watch-del-all, restart it completely:
- If you installed via Homebrew:
brew services restart watchman
Then try running your project again.
macOS uses a case-insensitive filesystem, but cached modules can get confused if you renamed a file (even just changing uppercase/lowercase). Make sure your import statements match the exact filename case—e.g., don't write import config from './config' if the file is named Config.js.
If the missing module ties to a native iOS dependency, try refreshing your pods:
- Navigate to the iOS directory:
cd ios pod deintegrate && pod install- Go back to your project root:
cd .. - Re-run:
react-native run-ios
Since it worked yesterday, do a quick check to make sure Config.js (or whatever module the error mentions) wasn't accidentally deleted, moved to a different folder, or renamed. A stray git commit or accidental drag-and-drop can easily cause this!
If none of these fix the issue, sharing the full error message (which should name the missing module) would help narrow things down even more.
内容的提问来源于stack exchange,提问作者Set Kyar Wa Lar

