score:1

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 this is a feature, you can request it to make them, or open a pull request for them
    • if its a bug, open a bug for them, or again make a pull request it to solve it

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)

score:1

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

enter image description here

step 2 : create update_note_modules.sh file

enter image description here

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

score:1

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.


Related Query

More Query from same tag