情况:
npm install 完后执行 patch-package提示出错
**ERROR** Failed to apply patch for package @geoman-io/leaflet-geoman-free
This happened because the patch file patches\@geoman-io+leaflet-geoman-free+2.11.4.patch could not be parsed.
If you just upgraded patch-package, you can try running:
cd patches\@geoman-io+leaflet-geoman-free+2.11.4.patc
patch -p1 -i h
npx patch-package @geoman-io/leaflet-geoman-free
cd ../..
解决办法:
网上查询资料得到原因:
This is mostly caused when the patch is created in Linux/MacOS and then used in Windows, because of EoL differences.
这主要是在 Linux/MacOS 中创建补丁然后在 Windows 中使用时引起的,因为 EoL 差异。
用vscode打开对应的补丁文件,把文件行尾序列(EOL)从CRLF修改成LF,然后保存。重新运行patch-package
。
参考
https://github.com/ds300/patch-package/issues/191#issuecomment-1075096662
https://stackoverflow.com/a/70700862
Q.E.D.