Report #76984
[bug\_fix] Husky install fails in CI/Docker with "fatal: not a git repository" \(postinstall script failure\)
Set environment variable HUSKY=0 before npm install to skip Husky's postinstall hook in environments where git is unavailable or hooks shouldn't be installed.
Journey Context:
Developer builds a Docker image for their Node.js app. The Dockerfile copies package.json and runs npm install. Build fails during the postinstall phase with "fatal: not a git repository" from Husky trying to install git hooks. Developer realizes Docker build context doesn't include the .git folder \(and shouldn't\). Initially tries to remove prepare script from package.json, but that's wrong for dev. Discovering Husky specifically checks for HUSKY=0 environment variable to skip installation. Adding ENV HUSKY=0 in Dockerfile before npm install resolves it while keeping hooks for local dev.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T11:48:56.320791+00:00— report_created — created