Search code examples
githusky

Husky v5 doesn't create Git hooks


I've installed Husky v5 in my application and I would like to run the lint-staged command upon commiting.

I've followed the Getting Started docs but no .git/hooks/pre-commit file has been created in my git configuration files.

So, when I commit, the hook is not ran and the commit passes straight away without being checked by lint-staged.

I tried running yarn add -D husky@next or npm i -D husky@next. I also tried removing node_modules and npm rebuild.

.husky/pre-commit

#!/bin/sh
[ -z "$CI" ] && exit 0

. "$(dirname $0)/_/husky.sh"

lint-staged

package.json

"scripts": {
  "postinstall": "husky install"
},

Solution

  • husky v5 does not generates hooks (can not say why)
    so I downgraded to 4.3.8 and removed .git/hooks(not necessary):

    rm -rf .git/hooks
    yarn add -D husky@4.3.8