From 07e110c57247a5def7516f8a6b0dab53524acec6 Mon Sep 17 00:00:00 2001 From: Stephanie Schofield Date: Fri, 9 Jan 2026 10:21:52 -0600 Subject: [PATCH 1/2] fix: skip Husky in CI and Docker production builds Setting HUSKY=0 environment variable prevents Husky from running during CI and Docker builds where git hooks are not needed. This fixes the 'husky: not found' error when npm ci --omit=dev skips installing devDependencies. --- .github/workflows/ci.yml | 2 ++ Dockerfile | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 581b0b3..5444b75 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,6 +25,8 @@ jobs: - name: Install dependencies run: npm ci + env: + HUSKY: 0 - name: Lint run: npm run lint diff --git a/Dockerfile b/Dockerfile index 2eb47f8..0bf8f64 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,8 +22,8 @@ WORKDIR /app # Copy package files COPY package*.json ./ -# Install production dependencies only -RUN npm ci --omit=dev +# Install production dependencies only (skip husky) +RUN HUSKY=0 npm ci --omit=dev # Copy built code from builder stage COPY --from=builder /app/dist ./dist From fcccd0e1bbdd5c8427a4124c28ffd0a6fbaf05fb Mon Sep 17 00:00:00 2001 From: Stephanie Schofield Date: Fri, 9 Jan 2026 10:28:16 -0600 Subject: [PATCH 2/2] refactor: replace HUSKY=0 workaround with .git directory check Instead of using HUSKY=0 environment variable, use postinstall script that checks for .git directory existence. This automatically installs git hooks only in development environments where a git repository exists, and skips installation in CI, Docker builds, and npm package installs. This is a cleaner solution that doesn't require environment variable configuration and handles all edge cases gracefully. --- .github/workflows/ci.yml | 2 -- Dockerfile | 4 ++-- package.json | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5444b75..581b0b3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,8 +25,6 @@ jobs: - name: Install dependencies run: npm ci - env: - HUSKY: 0 - name: Lint run: npm run lint diff --git a/Dockerfile b/Dockerfile index 0bf8f64..2eb47f8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,8 +22,8 @@ WORKDIR /app # Copy package files COPY package*.json ./ -# Install production dependencies only (skip husky) -RUN HUSKY=0 npm ci --omit=dev +# Install production dependencies only +RUN npm ci --omit=dev # Copy built code from builder stage COPY --from=builder /app/dist ./dist diff --git a/package.json b/package.json index 080ee71..c45d162 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "dev": "ts-node src/index.ts", "lint": "eslint src/**/*.ts", "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js", - "prepare": "husky" + "postinstall": "node -e \"try { require('fs').statSync('.git') && require('child_process').execSync('husky', {stdio: 'inherit'}) } catch (e) {}\"" }, "repository": { "type": "git",