Post

patch 方式修改 node_modules

  1. npm i patch-package –save-dev

  2. package.json
    1
    2
    3
    
     "scripts": {
       "postinstall": "patch-package"
     }
    
  3. 修改node_modules里面的代码

  4. 执行命令:npx patch-package

验证: 新增 patches 目录下有

1
2
3
4
5
<package_name>+<version>.patch

npx npkill -> npm install 

node_modules 内容自动被修改了
This post is licensed under CC BY 4.0 by the author.