Problem
Running npm install on Vercel (or any CI environment) fails because the prepare lifecycle script tries to run husky which is not available:
npm error code 127
npm error path /vercel/path0
npm error command failed
npm error command sh -c husky
sh: line 1: husky: command not found
npm error A complete log of this run can be found in:
npm error /vercel/.npm/_logs/2026-02-09T10_32_15_123Z-debug-0.log
The relevant script in package.json:
{
"scripts": {
"prepare": "husky"
}
}
Solution
Option 1: Make the prepare script tolerant of missing husky (recommended)
Update your package.json so the prepare script succeeds even when husky is not installed:
{
"scripts": {
"prepare": "husky || true"
}
}
Option 2: Disable husky via environment variable
Set the HUSKY environment variable to 0 in your Vercel project settings:
- Go to your Vercel project dashboard
- Navigate to Settings > Environment Variables
- Add a new variable:
HUSKY=0 - Redeploy
With this variable set, husky skips its installation entirely.
Why It Works
The prepare lifecycle script runs automatically after every npm install. Locally this is useful because it sets up git hooks via husky. However in CI environments like Vercel, husky is typically listed as a devDependency and may not be installed -- or git hooks are simply not needed during a build.
Adding || true to the command means that if husky exits with a non-zero code (including command not found, exit code 127), the shell falls back to true which always exits with code 0. This prevents npm install from treating the missing binary as a fatal error.
The HUSKY=0 environment variable approach works because husky v9+ checks for this variable on startup and exits immediately with code 0 when it is set, skipping all hook installation.
Context
- Husky v9+ changed its setup to use a single
huskycommand in thepreparescript (older versions usedhusky install) - Affects any CI provider: Vercel, Netlify, GitHub Actions, GitLab CI, CircleCI
- For monorepos using Turborepo or Nx, consider using
pinstto disablepreparein CI:"postinstall": "pinst --disable"and"prepublishOnly": "pinst --enable" - If using
npm ciwith--omit=dev, husky will not be installed at all, making|| trueessential - The
|| truepattern does not affect local development -- husky still installs hooks normally when available