I have a node package react-native-push-notification
for which i have made some changes in the packages to fulfil my requirement. But every time i do a npm install
the new (original package without my changes) package overlaps with my current package.
Is there any way i can restrict npm install
to ignore my modified package? And also i want to push this package to git.
Any lead will be highly appreciated.
If I understand you correctly you have made some changes to the already existing node package react-native-push-notification
and you would rather use your own version of it than the original.
You have a couple of options:
- In
package.json
change react-native-push-notification
to point to your git repo (e.g. your fork on github). This is not ideal since it makes semver problematic. But it works.
- Rename your fork of the package and use that directly from npm. E.g. rename to
react-native-push-notification2
or even better, use a scoped package name e.g. @yournick/react-native-push-notification
and publish that to npm. Change your package.json
to use this package instead.
- Convince the authors of the original package to incorporate your changes. This is the ideal solution, but might be difficult to get your patch merged etc.
patch-package
is exactly what you're looking for: https://github.com/ds300/patch-package
It will preserve your changes even after running npm install
.
The best way to handle this would be to fork the repo https://help.github.com/articles/fork-a-repo/.
This way, you have control of the contents of the package.
Then update your package.json
with your repo address.
I also would recommend not pushing your packages to Git. Packages are already under version control (in their own repo) and pushing to Git just bloats your repo for no reason.