简体   繁体   English

使用husky时如何解决.husky/_/husky.sh: No such file or directory 错误?

[英]How do I resolve .husky/_/husky.sh: No such file or directory error when using husky?

A project that I'm working on with colleagues uses husky versions ^5.1.0 and I keep getting this error when I'm trying to push my commit.我与同事合作的一个项目使用 husky 版本 ^5.1.0,当我尝试推送我的提交时,我不断收到此错误。

.husky/_/husky.sh: No such file or directory

How do I resolve this?我该如何解决这个问题?

I'm currently using git version 2.18.0.我目前使用的是 git 版本 2.18.0。

I have referred to https://github.com/typicode/husky/issues/712 and https://github.com/typicode/husky/issues/242 but it didn't help much.我参考了https://github.com/typicode/husky/issues/712https://github.com/typicode/husky/issues/242但它并没有多大帮助。

I eventually figured out that I had to delete node_modules and reinstall using我最终发现我必须删除 node_modules 并使用重新安装

yarn install

But this caused the.husky/_/husky.sh to be added to the commit which my colleagues did not want.但这导致 the.husky/_/husky.sh 被添加到我的同事不想要的提交中。

In order to avoid that I just had to update my git version via homebrew.为了避免这种情况,我只需要通过自制软件更新我的 git 版本。

I just ran我刚跑

brew update && brew upgrade

The brew update command updates homebrew itself, and the brew upgrade command updates all packages installed via homebrew. brew update 命令更新 homebrew 本身,而 brew upgrade 命令更新通过 homebrew 安装的所有软件包。

My git was updated to version 2.30.2我的 git 更新到版本 2.30.2

This allows the nested.gitignore file to ignore the.husky/_/husky.sh file in our project.这允许嵌套的.gitignore 文件忽略我们项目中的.husky/_/husky.sh 文件。

In my current scenario I was able to resolve the problem running npx husky-init and discarding all the changes it made to the files.在我当前的场景中,我能够解决运行npx husky-init并丢弃它对文件所做的所有更改的问题。

If this could help someone who had same issue as me如果这可以帮助与我有同样问题的人

I had the following code in the .husky/commit-msg我在.husky/commit-msg中有以下代码

npx --no -- commitlint --edit "${1}"

and just removing the " , it worked for me ie npx --no -- commitlint --edit ${1}只需删除" ,它对我有用,即npx --no -- commitlint --edit ${1}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM