Pre-commit hooks not working?

Below is my package.json, running meteor npm run lint or type works fine, how do I get the git pre-commit hooks to execute when I run git commit -m "message" ?

  "name": "react-meteor-example",
  "private": true,
  "scripts": {
    "start": "meteor run",
    "lint:client": "tslint --fix -c ./tslint.json './client/**/*.{ts,tsx}'",
    "lint:imports": "tslint --fix -c ./tslint.json './imports/**/*.{ts,tsx}'",
    "lint:server": "tslint --fix -c ./tslint.json './server/**/*.ts'",
    "lint": "npm run lint:client && npm run lint:server && npm run lint:imports",
    "type:server": "tslint -p ./tsconfig.json --type-check './server/**/*.ts'",
    "type:client": "tslint -p ./tsconfig.json --type-check './client/**/*.ts'",
    "type:imports": "tslint -p ./tsconfig.json --type-check './imports/**/*.ts'",
    "type": "npm run type:client && npm run type:server && npm run type:imports"
  "pre-commit": [
  "dependencies": {
    "@types/meteor": "^1.4.2",
    "@types/react": "^15.6.0",
    "babel-runtime": "^6.20.0",
    "meteor-node-stubs": "~0.2.4",
    "react": "^15.6.1",
    "react-addons-pure-render-mixin": "^15.6.0",
    "react-dom": "^15.6.1"
  "devDependencies": {
    "tslint": "^5.5.0",
    "tslint-react": "^3.1.0",
    "typescript": "^2.4.2"

I’m using husky for this. Very handy.

Here’s what it will look adapted to your package.json:

"precommit": "npm lint && npm type",
1 Like

Thanks @pierreeric , I’ll setup husky. Could you (or anyone) give me a technical reason to point to why the native git hooks don’t work?

Also, you linked to the official husky repo, but are you using meteor-husky ?
Announcing meteor-husky, the husky git hooks package for Meteor

I only use the regular one (the one linked previously).

So the fork really isnt necessary. The explanation did seem weird considering its already in the same npm environment. The meteor-husky package worked, but now I’ve verified that the official package works too.

this isn’t correct, regular husky may or may not work on your system depending on if you’ve installed node outside of Meteor, but it can lead to unpredictable results, especially across a team of more than one engineer with different machines. see this response