· Originally published on Medium

Husky doesn’t work in the latest install? Here’s the solution.

Recently I have to refactor the old project I worked on, and I found out according to this article, (which is a great guide btw) the handy commitlint shortcut can’t work normall…

  • husky
  • commitizen
  • ci

Recently I have to refactor the old project I worked on, and I found out according to this article, (which is a great guide btw) the handy commitlint shortcut can’t work normally anymore.

After a few hours of digging, I found out that this is a problem caused by the latest version of husky, which has a different approach to executing the pre-commit msg.

The solution isn’t complex at all. Make sure your husky is installed and the version is above 5.

Executing npx husky init to initialize, add “postinstall”: “husky install” to the scripts section in the package.json file is highly recommended.

Then, you can manually create hook actions with npx husky add .husky/pre-commit “lint-staged”. Or you can manually create these shell scripts located in the .husky folder. make sure it has correct permission for Husky to execute.

If you don’t familiar with setting this up, take look at the article above. Hopes this article can save you some time.

IMPORTANT:

# commit-msg
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx --no-install commitlint --edit $1

Then commit-msg hook file is a little different compares to the old one.

All articles