React native node modules: how to keep changes in Android modules in git?

你。 提交于 2019-12-13 03:15:02

问题


I have a React native project which requires to change some code inside the Android project of some library. The problem is that the library is positioned inside the node_modules folder and it's not been saved when pushing to get, because node_modules is ignored. I know I can remove node_modules from .gitignore but I think there should me another way, some better practice?


回答1:


Best way is that customize your module and use it from another address! for example I written many module and saved them like this :

   ./rootOfProject


        ./node_modules 

        ./custom_modules <-- here!

Note : In your android folder you need some changes! for example,

from :

project(':react-native-someModules').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-onesignal/android')

to :

project(':react-native-someModules').projectDir = new File(rootProject.projectDir, '../custom_modules/react-native-alarm-manager/android')

But why is this common solution?

Usually node_modules size is very large and it's not good to upload this to git or copy paste from a system to another, and for solve this problem, npm save module name's in package.json and everywhere that you want can run npm i and get node_modules!



来源:https://stackoverflow.com/questions/51796951/react-native-node-modules-how-to-keep-changes-in-android-modules-in-git

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!