#1561·husky

Different results with `npx husky init` and `npm run prepare`

Author: shardul-bCreated Feb 14, 2025Updated Feb 2, 2026

Troubleshoot

Context I have a monorepo like folder structure, but without a package.json in root folder.

root
| - node_project_1
| - node_project_2

Based on the docs I went inside node_project_1 and executed npx husky init in terminal. This command simply generated a .husky directory and a pre-commit file.

Image

My pre-commit hook didn't work.

Next I followed the "project not in git root directory" part and updated the prepare command to "prepare": "cd .. && husky node_project_1/.husky".

Post running npm run prepare I got a _ directory in .husky and pre-commit hook started working correctly.

Image

This was observed on a MAC with node version: v22.11.0 and husky: ^9.1.7

Thank you!