In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to modify the dependent library in node_modules". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn how to modify the dependent library in node_modules.
You need to simply modify the source code of @ tencent/wuji-server-lite. The package.json is as follows:
"dependencies": {"@ tencent/taf-config": "^ 2.0.4", "@ tencent/wuji-server-lite": "2.0.30", "patch-package": "^ 6.2.0"}
Generally speaking, we have two ways to do this:
Method 1: change the name of the modified code and re-package it to tnpm, and then refer to the new package directly.
Method 2: move the code copy out of node_modules as a local dependency
Either way, as a code cleanliness addict, I felt awkward. I changed a file and one or two lines of code, but I had to copy the whole project so bloated that in the end, I probably forgot where I changed it, and there was no diff to trace.
I consulted several nodejs-er at that time. Has nodejs provided any high-end ways to solve this problem in the past year or two when I haven't used nodejs, such as specifying that a file in node_modules can be replaced by another local one? The answer is no.
All of a sudden, I came up with a npm package to solve this kind of problem, and then I google it as usual, only to find that such a thing already exists, called patch-package (https://www.npmjs.com/package/patch-package). It was released two years ago. If I hadn't done Battle Royale Mobile Games halfway, maybe this library would have been made by me first, .
Since I don't need to make another wheel, I'll share how to use it next.
1. Local installation, npm I patch-package
2. Add {"postinstall": "patch-package"} to the scripts of package.json, which is a hook of npm and will be executed after the dependency package is install
3. Modify the code in node_modules
4. Generate patches,npx patch-package your-package-name
5. After submitting the patches, re-install the package and you will find that it is the result of your modification
Finally, there is a detailed comparison on the official website of the library, which describes when to use patch and when to fork.
Thank you for your reading, the above is the content of "how to modify the dependent library in node_modules", after the study of this article, I believe you have a deeper understanding of how to modify the dependent library in node_modules, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.