Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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/_/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.

like image 524
Bryan Lee Avatar asked Mar 15 '21 01:03

Bryan Lee


People also ask

How do you fix pre-commit hook failure?

#Solution 1: Delete the . git/hook folder and then do the npm install for reinstall husky. There are chances for conflicts with husky-generated files and . git/hook/ files.

How do you bypass pre-commit hook?

Use the --no-verify option to skip git commit hooks, e.g. git commit -m "commit message" --no-verify . When the --no-verify option is used, the pre-commit and commit-msg hooks are bypassed.


1 Answers

I eventually figured out that I had to delete node_modules and reinstall using

yarn install

But this caused the .husky/_/husky.sh to be added to the commit which my colleagues did not want.

In order to avoid that I just had to update my git version via homebrew.

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.

My git was updated to version 2.30.2

This allows the nested .gitignore file to ignore the .husky/_/husky.sh file in our project.

like image 190
Bryan Lee Avatar answered Oct 13 '22 01:10

Bryan Lee