2

I want to edit and remove some rows of code's from my node-modules but everytime I 'nmp install' my code will be overwriten. Is there a solution to edit files in my node-modules without overwriting them every time?

For example i wanna edit:

underlayColor: 'black',

from react-native-collapsible (A component I installed in react-native) to:

underlayColor: 'yellow',

Right now when I npm install it will be black again.

Levi Roest
  • 35
  • 2
  • 5
  • this looks like [the XY problem](http://xyproblem.info/). For sure you don't actually need to edit your node modules, it goes against how they are supposed to be used. You should be using a config file for the module (if it has one) or forking (I don't recommend this) or implementing the feature and submitting a pull request (yay open source contribution <3 ) or find another library. – Joe Lloyd May 07 '19 at 13:55

3 Answers3

2

Yes, but not directly,
U gotta fork the repo, make the changes, compile it, commit and push to your repo, npm install from that repo.

Still i would suggest to find a way to configure it, (example: eslint use .eslintrc, karma use karma.config.js, etc)

Nikko Khresna
  • 1,024
  • 8
  • 10
2

You shouldn't be editing code in node-modules, because it will get overwritten. If you really want to overwrite the code then you'll need to fork the module and publish the modified source yourself. I don't think you want to do this.

Just from a quick look at the documentation for react-native-collapsible, there is an underlayColor prop on the Accordion component (that I'm assuming) you're using, can you not just set the colour by passing your desired colour into that prop when you render the component.

<Accordion 
  ...
  underlayColor='yellow'
/>
Michael Curry
  • 991
  • 8
  • 20
0

You can fork the module and change code there in your forked repository. And then you can add this module to the package.json file. You can just put the Github repository URL in the package.json file. so you will have own version of the module.

Petr Vasilev
  • 150
  • 14