Search code examples
githusky

Husky commit-message hook not triggering


I'm trying to use commitlint lint commit messages against the Conventional Commit standard. Here is my relatively basic commitlint.config.js file:

export default {
  extends: ["@commitlint/config-conventional"]
};

When linting through the cli I get the errors I would expect.

git commit -m "This isn't a good commit message" > error ❌

git commit -m "chore(deps)!: upgrade something" > works ✅

However, when using Husky my pre-commit hooks work but not my commit message hooks. Here is my commit-msg file:

pnpx commitlint $1

However, refering back to the above example the results are as follows:

git commit -m "This isn't a good commit message" > works ✅

git commit -m "chore(deps)!: upgrade something" > works ✅

Meaning commitlint isn't working. Why isn't it triggering. I'm getting no errors.


Solution

  • Removing node_modules and running pnpm install. Fixed the issue. It seems I was using deprecated code.