husky: Husky cannot execute hooks
version
husky: “^1.3.1”, os: Mac node: v10.7.0
.huskyrc
{
"hooks": {
"pre-commit": "npm run lint"
}
}
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 27 (1 by maintainers)
husky: “^1.3.1”, os: Mac node: v10.7.0
{
"hooks": {
"pre-commit": "npm run lint"
}
}
Hi, I had the same issue. The hooks didn’t work. Here’s what I did.
Make sure you understand it changes the valid location of hook files. If you’re not familiar with this, talk to your peer before you run the commands.
$ git rev-parse --git-path hooks
.git/hooks
, rungit config core.hooksPath .git/hooks/
to solve the problem.It seems like the hooks files are created in
.git/hooks/
no matter what thecore.hooksPath
is.same here, this is a recurring issue with husky. previous version of husky you could fix this by doing rm -rf .git/hooks and then installing husky npm install -D husky
this doesn’t work for me, but maybe it does for y’all.
check .git/hooks if it’s empty try to uninstall husky and install again. my sh history
it helped me
THIS WORKED!!!
in the package.json file"
“husky”: { “hooks”: { “pre-commit”: “npm test”, “commit-msg”: “commitlint -E HUSKY_GIT_PARAMS” } },
first,you shoule check the
.git/hooks
if there are some hooks,such aspre-commit
,and check its content,if husky is corrected configed,you can see some content second,if the.git/hook
does not has hooks,that meanshusky
isnt take place.you shoule reinstall husky.for me at this moment i find the problemwhen i uninstall husky,the terminal show:
Husky requires Git >= 2.13.2, please update Git
so i update my git and reinstall husky, everything is okI am having the same issue but this is how it worked for me without specifying the custom hook inside package.json on React
OS: Windows 10 Node: v14.16.1 husky: ^6.0.0
npm install husky --save-dev
npx husky install
npx husky add .husky/pre-commit "npm run test"
git commit -m"custom message"
doesn’t work for me
Yup, deleting
.git/hooks
directory and reinstalling husky did it for me.Is there any reason why this runs this way? Is there no command that we can run within husky to check and create the hooks?
Do you also have to do the same thing every time you change your hooks? It seems a bit inconvenient if that’s the case.
Maybe we can submit an MR to get around the issue?
Still getting the above issue with Windows 10 / Husky 6.0.0
Official Docs supporting @simo54 's answer
Thanks it’s worked for me.
add your script into package.json like this for instance: { “scripts”: {
npx --no-install husky-upgrade
to automatically upgrade your configuration, then try again, it works for me.
@danielhdz56 this does fix it for me. thank you!
Same here.
husky: “^1.3.1” os: Windows 10 node: v10.15.0
There is no custom hooks that prevents Husky.