husky: husky pre-commit hook problem in windows

as a windows user I have a hard time to configure it to work, the hooks works on WSL, but not in git bash nor in Powershell.

this is the command I ran

$ HUSKY_DEBUG=1 yarn add -D husky
$ HUSKY_DEBUG=1 git commit # ...

the output:

$ HUSKY_DEBUG=1 yarn add -D husky
yarn add v1.22.4
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
[1/4] Resolving packages...
warning firebase-tools > google-auto-auth > request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
[2/4] Fetching packages...
info fsevents@2.1.2: The platform "win32" is incompatible with this module.
info "fsevents@2.1.2" is an optional dependency and failed compatibility check. Excluding it from installation.
info fsevents@1.2.9: The platform "win32" is incompatible with this module.
info "fsevents@1.2.9" is an optional dependency and failed compatibility check. Excluding it from installation.
info fsevents@2.1.3: The platform "win32" is incompatible with this module.
info "fsevents@2.1.3" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning " > bootstrap@4.4.1" has unmet peer dependency "jquery@1.9.1 - 3".
warning " > bootstrap@4.4.1" has unmet peer dependency "popper.js@^1.16.0".
warning " > react-ga@2.6.0" has unmet peer dependency "prop-types@^15.6.0".
warning "react-scripts > @typescript-eslint/eslint-plugin > tsutils@3.17.1" has unmet peer dependency "typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta".
[4/4] Building fresh packages...
success Saved lockfile.
success Saved 191 new dependencies.
info Direct dependencies
├─ @types/express@4.17.6
├─ @types/node@12.12.37
├─ firebase-tools@7.16.2
├─ husky@4.2.5
├─ picostyle-react@0.0.1
├─ picostyle@2.2.0
├─ prettier@1.19.1
├─ pretty-quick@2.0.1
└─ pusher-js@5.1.1
info All dependencies
├─ @google-cloud/paginator@2.0.3
├─ @google-cloud/precise-date@1.0.3
├─ @google-cloud/projectify@1.0.4
├─ @google-cloud/promisify@1.0.4
├─ @google-cloud/pubsub@1.7.2
├─ @grpc/grpc-js@0.6.18
├─ @types/body-parser@1.19.0
├─ @types/color-name@1.1.1
├─ @types/connect@3.4.33
├─ @types/duplexify@3.6.0
├─ @types/express@4.17.6
├─ @types/fs-extra@8.1.0
├─ @types/mime@2.0.1
├─ @types/node@12.12.37
├─ @types/qs@6.9.1
├─ @types/range-parser@1.2.3
├─ @types/serve-static@1.13.3
├─ agent-base@6.0.0
├─ ansi-align@2.0.0
├─ ansicolors@0.3.2
├─ archiver@3.1.1
├─ array-differ@3.0.0
├─ arrify@2.0.1
├─ basic-auth-connect@1.0.0
├─ basic-auth@2.0.1
├─ big-integer@1.6.48
├─ bignumber.js@7.2.1
├─ binary@0.3.0
├─ bl@4.0.2
├─ bluebird@3.4.7
├─ boxen@1.3.0
├─ buffer-crc32@0.2.13
├─ buffer-indexof-polyfill@1.0.1
├─ buffer@5.6.0
├─ capture-stack-trace@1.0.1
├─ cardinal@2.1.1
├─ chainsaw@0.1.0
├─ char-spinner@1.0.1
├─ cjson@0.3.3
├─ cli-boxes@1.0.0
├─ cli-color@1.4.0
├─ cli-spinners@2.3.0
├─ clone@1.0.4
├─ colors@1.0.3
├─ compare-semver@1.1.0
├─ compare-versions@3.6.0
├─ compress-commons@2.1.1
├─ configstore@5.0.1
├─ connect-query@1.0.0
├─ connect@3.7.0
├─ crc@3.8.0
├─ crc32-stream@3.0.1
├─ create-error-class@3.0.2
├─ cross-env@5.2.1
├─ crypto-random-string@2.0.0
├─ csv-streamify@3.0.4
├─ cycle@1.0.3
├─ defaults@1.0.3
├─ didyoumean@1.2.1
├─ duplexer2@0.1.4
├─ duplexer3@0.1.4
├─ es5-ext@0.10.53
├─ es6-promise@4.2.8
├─ es6-promisify@5.0.0
├─ es6-weak-map@2.0.3
├─ event-emitter@0.3.5
├─ event-target-shim@5.0.1
├─ exit-code@1.0.2
├─ ext@1.4.0
├─ eyes@0.1.8
├─ fast-text-encoding@1.0.2
├─ fast-url-parser@1.1.3
├─ find-versions@3.2.0
├─ firebase-tools@7.16.2
├─ flat-arguments@1.0.2
├─ fs-constants@1.0.0
├─ fstream@1.0.12
├─ gcp-metadata@0.6.3
├─ glob-slash@1.0.0
├─ glob-slasher@1.0.1
├─ global-dirs@0.1.1
├─ google-auto-auth@0.10.1
├─ google-gax@1.12.0
├─ google-p12-pem@2.0.4
├─ got@6.7.1
├─ gtoken@4.1.4
├─ home-dir@1.0.0
├─ https-proxy-agent@5.0.0
├─ husky@4.2.5
├─ ignore@5.1.4
├─ import-lazy@2.1.0
├─ inquirer@6.3.1
├─ is-installed-globally@0.1.0
├─ is-npm@1.0.0
├─ is-path-inside@1.0.1
├─ is-promise@2.2.2
├─ is-redirect@1.0.0
├─ is-retry-allowed@1.2.0
├─ is2@2.0.1
├─ jju@1.4.0
├─ join-path@1.1.1
├─ json-bigint@0.3.0
├─ json-parse-helpfulerror@1.0.3
├─ jsonparse@1.3.1
├─ jsonschema@1.2.6
├─ JSONStream@1.3.5
├─ jsonwebtoken@8.5.1
├─ jwa@1.4.1
├─ klaw@1.3.1
├─ latest-version@3.1.0
├─ lazystream@1.0.0
├─ listenercount@1.0.1
├─ lodash._isnative@2.4.1
├─ lodash._shimkeys@2.4.1
├─ lodash.defaults@4.2.0
├─ lodash.difference@4.5.0
├─ lodash.flatten@4.4.0
├─ lodash.includes@4.3.0
├─ lodash.isarguments@3.1.0
├─ lodash.isboolean@3.0.3
├─ lodash.isinteger@4.0.4
├─ lodash.isnumber@3.0.3
├─ lodash.isobject@2.4.1
├─ lodash.keys@2.4.1
├─ lodash.once@4.1.1
├─ lodash.snakecase@4.1.1
├─ lodash.toarray@4.4.0
├─ lodash.union@4.6.0
├─ lodash.values@2.4.1
├─ log-symbols@2.2.0
├─ lowercase-keys@1.0.1
├─ lru-queue@0.1.0
├─ marked-terminal@3.3.0
├─ marked@0.7.0
├─ memoizee@0.4.14
├─ morgan@1.10.0
├─ mri@1.1.5
├─ multimatch@4.0.0
├─ nash@3.0.0
├─ node-emoji@1.10.0
├─ open@6.4.0
├─ opencollective-postinstall@2.0.2
├─ ora@3.4.0
├─ p-defer@3.0.0
├─ package-json@4.0.1
├─ picomatch@2.2.2
├─ picostyle-react@0.0.1
├─ picostyle@2.2.0
├─ pkginfo@0.3.1
├─ please-upgrade-node@3.2.0
├─ plist@3.0.1
├─ prettier@1.19.1
├─ pretty-quick@2.0.1
├─ protobufjs@6.9.0
├─ pseudomap@1.0.2
├─ pusher-js@5.1.1
├─ redeyed@2.1.1
├─ registry-auth-token@3.4.0
├─ registry-url@3.1.0
├─ router@1.3.5
├─ rsvp@3.6.2
├─ semver-compare@1.0.0
├─ semver-diff@2.1.0
├─ semver-regex@2.0.0
├─ stack-trace@0.0.10
├─ strip-final-newline@2.0.0
├─ superstatic@6.0.4
├─ supports-hyperlinks@1.0.1
├─ tar-stream@2.1.2
├─ tcp-port-used@1.0.1
├─ term-size@1.2.0
├─ timed-out@4.0.1
├─ toxic@1.0.1
├─ traverse@0.3.9
├─ try-require@1.2.1
├─ typedarray-to-buffer@3.1.5
├─ unique-string@2.0.0
├─ universal-analytics@0.4.20
├─ unzip-response@2.0.1
├─ unzipper@0.10.11
├─ url-join@0.0.1
├─ url-parse-lax@1.0.0
├─ valid-url@1.0.9
├─ wcwidth@1.0.1
├─ which-pm-runs@1.0.0
├─ widest-line@2.0.1
├─ winston@1.1.2
├─ write-file-atomic@3.0.3
├─ xmlbuilder@9.0.7
├─ xmldom@0.1.31
└─ zip-stream@2.1.3
Done in 39.67s.
$ HUSKY_DEBUG=1 git commit -m "test"
husky:debug husky v4.2.5 - pre-commit
husky:debug Current working directory is /d/workspace/aaaa/projectb
/usr/bin/bash: D:workspaceaaaprojectbnode_modules.binhusky-run: command not found
husky:debug yarn run --silent husky-run exited with 127 exit code
Can't find Husky, skipping pre-commit hook
You can reinstall it using 'npm install husky --save-dev' or delete this hook
husky:debug husky v4.2.5 - prepare-commit-msg
husky:debug Current working directory is /d/workspace/aaaa/projectb
husky:debug prepare-commit-msg config not found, skipping hook
husky:debug husky v4.2.5 - commit-msg
husky:debug Current working directory is /d/workspace/aaaa/projectb
husky:debug commit-msg config not found, skipping hook
husky:debug husky v4.2.5 - post-commit
husky:debug Current working directory is /d/workspace/aaaa/projectb
husky:debug post-commit config not found, skipping hook
[prettier f05c2ef] dsfsd
 1 file changed, 172 insertions(+), 153 deletions(-)
 rewrite src/components/pages/FeaturesPage.jsx (72%)

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 1
  • Comments: 21 (2 by maintainers)

Most upvoted comments

not stale

The latest npm release appears to have broken this again. npm rebuild did not work. npx also doesn’t work with the latest default 7.5.2 release of npm.

Removing .git/hooks folder and then running npm rebuild worked for me

Hey, @typicode… I’m having the same error, just to add something to the discussion, running the command you asked, I receive the following error:

/usr/bin/bash: C:UsersdouglDocumentsProjectsSomeProjectnode_modules.binhusky-run: command not found

What I’ve tried:

  • Reinstall husky
  • Remove .git/hooks folder and create it again

Using with Windows 10 Husky version: “husky”: “^4.2.5”

I’ve tested with version 3 and it is running fine without it. I’ll try to track the version that it started.

Yep, using npm instead of yarn solved the issue.

@douglas-pires Yes, that’s a temporary fix. Given npx runner is shipped with node.js, that should always work.