admin管理员组文章数量:1392007
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 ponent 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 puter 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 ponent 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.
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 ponent 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 puter 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 ponent 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.
- 3 fork that library on github, make the changes. Use it on package json instead of npm version – Hariks Commented Sep 7, 2019 at 10:57
- 2 or you can try exploring this patching module npmjs./package/… – Hariks Commented Sep 7, 2019 at 11:04
3 Answers
Reset to default 2I would remend https://github./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.
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 ponent over their ponent, 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 ponent from the scratch using their dependencies, in this case this is not a Wrapper ponent but a whole new ponent, avoid this option if you can just wrap their ponent to achieve what you want)
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
本文标签: javascriptHow to persist changes made in nodemodulesStack Overflow
版权声明:本文标题:javascript - How to persist changes made in node_modules? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744763919a2623918.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论