Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

prettier

husky

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"
    }
  }
}
like image 976
Mohammad Reza Ghasemi Avatar asked Jun 24 '26 04:06

Mohammad Reza Ghasemi


2 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

like image 91
Goosterhof Avatar answered Jun 27 '26 20:06

Goosterhof


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

npx pretty-quick --staged
like image 24
Pramod Patil Avatar answered Jun 27 '26 21:06

Pramod Patil



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!