React Native Environment Info:
System:
OS: macOS High Sierra 10.13.6
CPU: x64 Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz
Memory: 344.85 MB / 8.00 GB
Shell: 5.3 - /bin/zsh
Binaries:
Node: 9.11.1 - /usr/local/bin/node
npm: 6.4.1 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.0, macOS 10.14, tvOS 12.0, watchOS 5.0
IDEs:
Android Studio: 3.0 AI-171.4443003
Xcode: 10.0/10A255 - /usr/bin/xcodebuild
npmPackages:
react: 16.6.0-alpha.0 => 16.6.0-alpha.0
react-native: 0.57.3 => 0.57.3
npmGlobalPackages:
create-react-native-app: 1.0.0
react-native-cli: 2.0.1
My .babelrc config /Users/my-computer/projects/mobile/.babelrc
{
"presets": ["module:metro-react-native-babel-preset", "module:react-native-dotenv"],
"plugins": [
["module-resolver", {
"root": ["./app"],
"extensions": [".js", ".ios.js", ".android.js"],
"cwd": "babelrc"
}]
],
"env": {
"development": {
"plugins": ["functional-hmr"]
},
}
However, I get this error:
bundling failed: Error: Unable to resolve module `../../../../../app/locales/i18n`.
Indeed, none of these files exist:
* `/Users/my-computer/app/locales/i18n(.js|.ios.js)
The path should be
/Users/my-computer/projects/mobile/app/locales/i18n
but it get resolved to
/Users/my-computer/app/locales/i18n
It turns out the problem comes from react-native run-ios itself when it opens the React Native Metro Bundler in a wrong directory. Running react-native start first in the correct folder helps.
@liemdo is there any fix for that?
Update: I had to do react-native start --reset-cache and then call react-native run-ios
Getting the same issue, is there any other solution instead of running yarn start --reset-cache every time ?
Indeed, it's annoying having to run npm start -- --reset-cache every time when starting the dev app.
+1
My issue was running the comand from a symlink folder in Linux. Running "react-native start" from "full path" resolved the issue
Most helpful comment
@liemdo is there any fix for that?
Update: I had to do
react-native start --reset-cacheand then callreact-native run-ios