Search code examples
githuskygit-husky

How do I resolve .husky/_/husky.sh: No such file or directory error?


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/_/husky.sh: No such file or directory

How do I resolve this?

I'm currently using git version 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.


Solution

  • I solved the issue by deleting node_modules and running:

    yarn install
    

    However, this added .husky/_/husky.sh to the commit, which my colleagues didn't want. To fix this, I updated Git via Homebrew:

    brew update && brew upgrade
    

    This updated Git to version 2.30.2, which allowed the nested .gitignore to correctly ignore the .husky/_/husky.sh file.