当前位置:网站首页>Patch package cannot be used to patch pnpm
Patch package cannot be used to patch pnpm
2022-06-21 19:40:00 【InfoQ】
Introduce
- own fork A source code modification , After the repair, it can be packaged locally and used directly . If you want to share your research results with others , It can be transmitted to npm Warehouse or submit PR Feed source warehouse . There is a drawback to this approach , It is difficult to keep notes synchronized with the official library .
- Waiting for the library author to repair . This way is not very reliable , Because open source authors are usually busy , Your needs may not be at the top .
How to use patch-package
- from node_modules Find npm Depend on the source code of the package , Fix errors in dependent packages
vim node_modules/my-package/common.js
- function patch-package Create a .patch file ,.patch Files can be automatically npm Identify and apply
npx patch-package my-package
- Submit the patch file to share the fix with your team
git add patches/my-package+3.14.15.patch
git commit -m "fix common.js in my-package"
- Install the dependent package
npm i -D patch-package
- stay package.json Add a script to postinstall, Support in
npm iThen it will be executed automatically patch-package Apply the patch to
"scripts": {
"postinstall": "patch-package"
}
npx patch-package my-package**ERROR** No package-lock.json, npm-shrinkwrap.json, or yarn.lock file.
You must use either [email protected]>=5, yarn, or npm-shrinkwrap to manage this project's
dependencies.
pnpm patch up
npm i- Modify node_modules Depends on the package source file , Copy to the following directory
patchesUnder the table of contents
vim node_modules/my-package/common.js
cp node_modules/my-package/common.js patches/my-package
- Create a new script in the project postinstall.js, Implement the operation of overwriting the source code file
copyFileSync('./patches/my-package/common.js', './node_modules/my-package/common.js');
function copyFileSync(source, target) {
var targetFile = target;
// If target is a directory, a new file with the same name will be created
if (fs.existsSync(target)) {
if (fs.lstatSync(target).isDirectory()) {
targetFile = path.join(target, path.basename(source));
}
}
fs.writeFileSync(targetFile, fs.readFileSync(source));
}
- package.json One more in postinstall The command points to our script
"scripts": {
"postinstall": "node scripts/postinstall.js"
}
summary
Reference resources
- pnpm Not available in patch-package patch up
- patch-package
- pnpm
- Hands teach you how to use patch-package to npm Pack and patch
边栏推荐
- Literature analysis CiteSpace 6.1.2 download and installation tutorial
- Gartner 网络研讨会 “九问数字化转型” 会后感
- [pwn基础]Pwntools学习
- R语言使用epiDisplay包的dotplot函数通过点图的形式可视化不同区间数据点的频率、使用by参数指定分组参数可视化不同分组的点图分布、使用cex.main参数指定可视化图像标题文本字体的大小
- In air operation, only distance mapping is used to robustly locate occluded targets (ral2022)
- Dynamic programming [II] (linear DP)
- linux-mysql-命令
- EasyCVR智能边缘网关硬件如何设置通电自启动?
- 11 introduction and installation of beautiful soup parsing library
- CloudCompare&PCL 根据匹配点计算变换矩阵
猜你喜欢

Is there a Hongmeng version of the song ordering system? Lao Wang was the first to experience it

nacos-配置中心-源码

11 Beautiful Soup 解析库的简介及安装

Notes on writing questions in C language -- find s=a+aa+aaa+aaaa+aa Value of a

基于ASP.NET开发的企信通源码 短信管理平台源码

Mvcc implementation principle of MySQL

vivo 容器集群监控系统架构与实践

11 introduction and installation of beautiful soup parsing library

医疗费用清单秒速录入,OCR识别助力效率倍增

一次 MySQL 误操作导致的事故,「高可用」都顶不住了!
随机推荐
Flink 系例 之 TableAPI & SQL 与 示例模块
论文解读(USIB)《Towards Explanation for Unsupervised Graph-Level Representation Learning》
2022年6月25日PMP考试通关宝典-4
After Hongmeng, Huawei announced that it would donate to Euler again. What impact is expected to be brought to the industry by the donations of Hongmeng and Euler?
一次 MySQL 误操作导致的事故,「高可用」都顶不住了!
Notes on writing questions in C language -- find s=a+aa+aaa+aaaa+aa Value of a
CloudCompare&PCL 点云点匹配(基于欧式距离)
Nepal graph has settled in Alibaba cloud computing nest to help enterprises build a super large-scale map database on the cloud
Use the uniapp framework to build the zheliban micro application (single sign on, embedded point, aging adaptation, RPC gateway)
轻松入门自然语言处理系列 专题6 代码实战──基于语言模型的拼写纠错
Shang Silicon Valley Shang Silicon Valley | what is Clickhouse table engine memory and merge
The R language catiols package divides the data, randomforest package constructs the random forest model, uses the importance function to calculate the importance of each feature in the random forest
【区间和专题の前缀和】前缀和 + 哈希表 运用题
2022年下半年深圳地区数据分析师认证(CPDA),[进入查看]
插入类排序法
系统集成项目管理工程师(软考中级)怎么备考?
[comprehensive pen test] difficulty 2.5/5: "tree array" and "double tree array optimization"
In air operation, only distance mapping is used to robustly locate occluded targets (ral2022)
线上开期货户是否安全啊?不去线下可以开户吗?
298th weekly match