当前位置:网站首页>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
边栏推荐
- 动态规划【二】(线性dp)
- The GLM function of R language is used to build a binary logistic regression model (the family parameter is binomial), and the coef function is used to obtain the model coefficients and analyze the me
- R语言使用epiDisplay包的dotplot函数通过点图的形式可视化不同区间数据点的频率、使用by参数指定分组参数可视化不同分组的点图分布、使用cex.main参数指定可视化图像标题文本字体的大小
- The dist function of R language calculates the distance between two samples in dataframe data and returns the distance matrix between samples. The distance matrix is input to the hclust function for h
- GetEmptyBlcoksPre Info
- 在 KubeSphere 上部署 Apache Pulsar
- [interval and topic prefix sum] line segment tree (dynamic open point) application problem
- Forwarding to remind metamask how to deal with the potential private key disclosure of the expansion program
- Linux MySQL command
- 医疗费用清单秒速录入,OCR识别助力效率倍增
猜你喜欢
随机推荐
Summary of the 13th week
R language uses GLM function to build Poisson regression model, and coef function to obtain the coefficients of Poisson regression model and analyze the effects of various variables
Is it safe to open futures accounts online? Can I open an account without going offline?
SQL operation: with expression and its application
NPDP|如何做好产品生命周期管理?
谷歌浏览器80版本以后,如何处理出现的问题SameSite跨域问题
[Shangshui Shuo series] day one
鸿蒙之后,华为宣布再将捐赠欧拉,鸿蒙和欧拉的捐赠预计将给业界带来哪些影响?
Alibaba cloud Yum source configuration
动态规划【一】(背包问题)
论文解读(USIB)《Towards Explanation for Unsupervised Graph-Level Representation Learning》
R语言使用epiDisplay包的dotplot函数通过点图的形式可视化不同区间数据点的频率、使用by参数指定分组参数可视化不同分组的点图分布、使用cex.main参数指定可视化图像标题文本字体的大小
W10添加系统环境变量Path
[high frequency interview questions] linked list interview questions with 1/5 difficulty and lower difficulty
Second cloud's original fully compatible solution for Xinchuang is upgraded to help accelerate the implementation of Xinchuang industry
2022年6月25日PMP考试通关宝典-5
Double pointer 1day8 of daily practice of Li Kou
OGG-21.3 报错 OGG-00768 Failed to Map database character to ULibCharSet
Ogg-21.3 error reporting ogg-00768 failed to map database character to ulibcharaset
Excel文件加密的两种方式








