问题描述
我使用的 Chart 库有错误,为了解决这个问题,我应该运行这个脚本:https://github.com/plouc/nivo/blob/master/scripts/patch-react-spring.js。在构建之前。我想过在package.json下的根目录添加“prebuild”:“npm run patch-react-spring.js”并添加patch-react-spring.js文件。但是,当我执行 npm run patch-react-app 或 npm run prebuild 时,我收到错误:npm ERR!缺少脚本:patch-react-spring.js
这是该项目的 GitHub 存储库:https://github.com/JonasHendel/SunPosition
解决方法
你可以尝试使用这个库
https://www.npmjs.com/package/patch-package
# fix a bug in one of your dependencies
vim node_modules/some-package/brokenFile.js
# run patch-package to create a .patch file
npx patch-package some-package
# commit the patch file to share the fix with your team
git add patches/some-package+3.14.15.patch
git commit -m "fix brokenFile.js in some-package"
在 package.json 中
"scripts": {
"postinstall": "patch-package"
}