在实际项目开发过程中会用到很多第三方包,其中有一些错误或者需要做兼容处理的地方,这时就需要能够在我们的项目中修改特定文件,并把这些修改固定下来,不被install后还原会去。以下介绍三种方法。
一、patch-package
该方法需额外安装 patch-package,还需执行命令,生成补丁文件。就能在每次执行install命令时将补丁内容替换到node_modules中对应的源文件中。
1、安装 patch-package
npm install patch-package --D
yarn add --dev patch-package postinstall-postinstall