error Command "husky-run" not found.
I've faced an issue with husky which prevents me from committing, It's kind of confusing because it was working before that, but now, I'm getting an error which says error Command "husky-run" not found.
I've checked it and it was in package.json and also I upgraded it and removed and installed it again, but it doesn't fix that,
How can we fix it? (someone on stackoverflow said we should remove git hooks and so on, which seems not a very good solution).
this is my pre-commit:

@SeyyedKhandon The API changed a lot from v4 to v5. Downgrade to v4 and your issue should be fixed or look at the migration guide https://typicode.github.io/husky/#/?id=migrate-from-v4-to-v5
@SeyyedKhandon The API changed a lot from v4 to v5. Downgrade to v4 and your issue should be fixed or look at the migration guide https://typicode.github.io/husky/#/?id=migrate-from-v4-to-v5
I had the problem with v4 which made me think it may be fixed with the upgrade to v5, which it didn'tš¢.
A few action to take in order to narrow the problem source:
- place an
echo "pre-commit hook"in pre-commit file - try to run it directly from shell
- check if there is any relics from v4 in
.git/hooksand delete them (you can keep everything else)
Could you please tell us if you are committing from your terminal or from a GUI app (if so, which one)?
So far, your pre-commit file is empty, is it normal?
Are you using yarn or npm?
I had this issue when Dependabot bumped Husky to v5. To resolve I did the following:
- Renamed the Husky git hooks found in
.git/hooksof my repo to*.bak - Ran
yarn husky initwhich created a new.huskydirectory in the root with apre-commithook that runsnpm test(which can be changed to whatever you wanna run)
This worked for me, and I then cleaned the old Husky git hooks out once I was sure everything was good.
After struggling with this issue, I ended up with a new clone of my project and use yarn again to fix this issue by renewing husky.
Yarn doesn't seem to run husky's uninstall script when upgrading husky, which leaves some files in .git/hooks.
Two ways to fix that:
- Check that you don't have anything personal in
.git/hooks(this should be the case for most people) and delete.git/hooks. - š Use @schinery solution and run
yarn husky init(recommended) (you can still remove everything in.git/hooks, if you want to clean any artifact lefts by husky v4 :)
for husky version 6 run yarn husky install (@typicode solution)