-
Notifications
You must be signed in to change notification settings - Fork 0
React Native
Marwan Zogheib edited this page Jun 29, 2024
·
12 revisions
- Follow all instructions at here for the base installation. Note the following:
- Name cannot be in kebab-case. See here. So choose snake_case.
-
--directory client-mobileto install into directory namedclient-mobile. Otherwise it will install intoclient_mobile, which is not consistent with other directory names. -
--pm yarnto use Yarn. Otherwise apackage-lock.jsonwill be created.
cd packages
npx react-native@latest init client_mobile --pm yarn --directory client-mobile-
React Native needs extra care in a monorepo. Do the following:
- Do not hoist any of its dependencies by adding this to
client-mobile/package.json"installConfig": { "hoistingLimits": "workspaces" }
- Watch the root folder in order to import packages from within the monorepo
// metro.config.js const config = { watchFolders: [path.resolve(__dirname, "../..")], };
- Do not hoist any of its dependencies by adding this to
-
Re-install (from the root directory)
yarn clean-node-modules
yarn- Run the following for the iOS build.
cd packages/client-mobile/ios
bundle install
bundle exec pod install- For Android, make sure all the right tools are installed and at the right version.
npx react-native doctor- If running a local api, e.g. on
http://localhost:3001, the emulator needs access to that port. - See here and here.
adb reverse tcp:3001 tcp:3001- iOS
cd ios
rm -rf build/ Pods/
bundle install
bundle exec pod install- Android
cd android
./gradlew clean- NPM
yarn clean-node-modules
yarn- After a reinstall of Node.js using nvm the iOS project may be looking for the node binary in an old location
- This will lead to a build failure in Xcode with something like
/usr/local/bin/node: No such file or directory- To fix this, find the new location and specify it in
.xcode.env.local
which node
/Users/yourname/.nvm/versions/node/v18.20.3/bin/node
// copy the output into .xcode.env.local
export NODE_BINARY=/Users/yourname/.nvm/versions/node/v18.20.3/bin/node