React Native Node Modules:如何在git中保持Android模块中的更改? [英] React native node modules: how to keep changes in Android modules in git?

查看:152
本文介绍了React Native Node Modules:如何在git中保持Android模块中的更改?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个React本机项目,需要在某些库的Android项目中更改一些代码.问题在于该库位于node_modules文件夹内,并且在推送获取时未保存该库,因为会忽略node_modules.我知道我可以从.gitignore中删除node_modules,但是我认为应该以另一种方式进行一些更好的练习吗?

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?

推荐答案

最好的方法是自定义您的模块并从另一个地址使用它!例如,我编写了许多模块,并像这样保存它们:

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!

注意: 在您的android文件夹中,您需要进行一些更改!例如

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

来自:

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

至:

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

但是为什么这是常见的解决方案?

But why is this common solution?

通常node_modules的大小很大,将其上传到git或将粘贴从一个系统复制到另一个系统是不好的,为了解决此问题,npm将模块名称保存在package.json中,并且您想在任何可以运行的地方npm i并获取node_modules!

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!

这篇关于React Native Node Modules:如何在git中保持Android模块中的更改?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆