How do I resolve .husky/_/husky.sh: No such file or directory error when using husky?
Asked Answered
S

4

20

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.

Stanley answered 15/3, 2021 at 1:56 Comment(0)
S
10

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.

Stanley answered 15/3, 2021 at 1:56 Comment(0)
C
7

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.

Conni answered 1/3, 2022 at 10:10 Comment(3)
where did you run npx husky-init?Japha
i mean, where directory?Japha
I run it in the root directory of the repositoryConni
H
2

You can use this command after remove file: _/husky.sh

git config --unset core.hooksPath
Helluva answered 3/7, 2023 at 14:0 Comment(0)
E
0

If this could help someone who had same issue as me

I had the following code in the .husky/commit-msg

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

and just removing the ", it worked for me i.e npx --no -- commitlint --edit ${1}

Effeminize answered 17/1, 2023 at 10:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.