Skip to content

prepare: husky breaks npm install --omit=dev (pi extension update fails on Windows) #22

Description

@baoyu0

Problem

Installing this package the way the pi coding agent installs git-based extensions fails on Windows:

> npm install --omit=dev
npm notice run pi-agenticoding@0.4.0 prepare
npm notice run husky
'husky' is not recognized as an internal or external command,
operable program or batch file.
npm error code 1
npm error path <checkout>
npm error command failed
npm error command C:\windows\system32\cmd.exe /d /s /c husky

pi update --extensions runs npm install --omit=dev in the git checkout of every git-based extension (see getGitDependencyInstallArgs() in @earendil-works/pi-coding-agent's dist/core/package-manager.js, which returns ["install", "--omit=dev"]). Since husky is only listed under devDependencies, it is never installed with --omit=dev, yet the prepare lifecycle script still runs the bare husky command → command not found → the install aborts.

Suggested fix

Make the prepare script resilient when husky isn't installed (e.g. under --omit=dev):

"prepare": "node -e \"try{require('node:child_process').execSync('husky',{stdio:'inherit'})}catch{process.exit(0)}\""

This runs husky when it is present (normal development workflow) and no-ops otherwise (managed/CI installs). Alternatively, move the git-hook setup out of prepare, or drop it entirely since consumers of the package don't need the repo's git hooks.

Environment

  • Windows 11 (10.0.26200)
  • node v24.19.0, npm 12.0.1
  • Reproduced with pi update --extensions and with a plain npm install --omit=dev inside the checkout.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions