Reputation: 6491
I'm using Card
from react-native-elements
and I got rid of the
{image && ..... <BackgroundImage .....
part because I wanted to add a placeholder image (activity indicator) before the image was downloaded, so that I dont just see a blank area before the image fades in.
Anyway, I replaced that part with another component and it just hit me -- my .gitignore
ignores /node_modules
. If I were to make such changes as I did to the Card
and then buy a new computer and clone my repo, running npm install
will not give me the npm modules with my changes.
How can I get around this? I don't want to push my whole node_modules directory. Also, I thought about just making my own component based on Card
, but it has way too many dependencies and imports that I don't want to get into resolving and copying over to my project as well if I don't have to.
Upvotes: 4
Views: 4248
Reputation: 347
I would recommend https://github.com/ds300/patch-package here; makes patches and apply them consistently to things in node_modules. Often useful for fixes that were never pushed to certain versions of packages.
Upvotes: 2
Reputation: 3636
We have solve this issue by creating update_note_modules.sh(shell executables) file and run this file after every npm/yarn install
Step 1: Save copy of your code from node_modules to your main application folder . We have created "core" folder and save copy there
Step 2 : Create update_note_modules.sh file
File Code
echo "Updating react-native-dropdownalert"
cp core/react-native-dropdownalert/DropdownAlert.js node_modules/react-native-dropdownalert/DropdownAlert.js
echo "node_modules updated"
Note: Path will change according to your project
Step 3: Run update_note_modules.sh after every npm/yarn install
Just paste the path of file in terminal and hit enter to execute file
/path to file/update_note_modules.sh
Upvotes: 1
Reputation: 8034
You should never make changes to node_modules due to the reason you have described, Your changes are just temporary, and if you decide to update the dependency your changes will be lost.
Depending on your reason for changing the code, you can do other things:
If you want to make changes that persist then you have to make your own library that is based on theirs (Assuming their license allowing you yo do so), This is a really bad option, you lose all the automatic updates, and bug fixes.
What you should do is what you suggested, is that you should build a wrapper component over their component, and in that case you are not adding any new dependencies (the dependencies they use will be there anyway, unless you decide to build the component from the scratch using their dependencies, in this case this is not a Wrapper component but a whole new component, avoid this option if you can just wrap their component to achieve what you want)
Upvotes: 1