0
I want to create a monorepo with Yarn to work with React-Native, this is necessary because I want to keep backend frontend and app in the same repository. My problem occurs when loading the app to my emulator, I will describe what I have so far.
I create the project with the command yarn react-native init App
inside the directory Packages, then remove the file Yarn.lock and the directory node_modules from within the project have been created. I return to the root of my project and run yarn
so that dependencies are reinstalled.
Then I need to change some path settings in order to install the App in emulated, these changes consist of incrementing ".. /.. /" in the files described below.
App/android/Settings.Radle
apply from: file("../../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
App/android/app/build.Radle
apply from: file("../../../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
The excerpts described above correspond to the final result after editing.
Now I can execute yarn android
in the application and the same will install my App in the emulator "correctly".
After installing the App in emulated (or before that, I have both attempts), I run yarn start
to initialize the Bundle of my App, this command runs without any error (so far), but when I run the Reload in my app in the emulator I get the following error:
error: Error: Unable to resolve module
@babel/runtime/helpers/interopRequireD
efault
from index.js
: @Babel/Runtime/helpers/interopRequireDefault could not be found Within the project.
Just to highlight, the app was installed in the emulator but at no time executed correctly, in case I run Bundle before installing the app on mobile, after running the yarn android
the application will open and the same error is issued immediately on Bundle.
My directory structure is as follows:
node_modules
packages
- Server
- Web
- App
- - node_modulos
- - android
- - ios
- - package.json
- - *outros arquivos
package.json
yarn.lock
Some links were very useful to me, but they didn’t solve my problem
https://github.com/react-native-community/cli/issues/591
https://github.com/react-native-community/cli/issues/656
https://github.com/react-native-community/cli/issues/877
https://stackoverflow.com/questions/49373181/babel-preset-not-loading-on-monorepo-project
Environmental data:
OS: Ubuntu 16.04 LTS
Yarn: 1.22.4
Emulator: Android Studio
Note: the project works normally if your do not put it within the Yarn monorepo structure, which indicates that there is no problem with the emulator.
I really appreciate it if someone can tell me what I’m missing here.