Pre-commit hook (husky + pretty-quick) doesn't work

Viewed 5351

I've configured prettier and pre-commit hook like before but in my new project husky doesn't run before any commit!

Below is part of the project package.json file:

{
  ...,
  "devDependencies": {
    "husky": "^4.3.6",
    "prettier": "2.2.1",
    "pretty-quick": "^3.1.0"
  },
  "husky": {
    "hooks": {
      "pre-commit": "pretty-quick --staged"
    }
  }
}
3 Answers

I was running into the same problem but i'm using husky ^5.0.9.
Then i read the docs that you need to run npx husky install.
That fixed it for me

In pre-commit, use npm in front of pretty-quick

npx pretty-quick --staged

you should use "husky": "^2.7.0", "prettier": "^1.18.2", "pretty-quick": "^1.11.1",

Related