husky: git hook install triggered via npm but not yarn
Do you want to request a feature or report a bug? => Bug
Installing the git hook is only triggered when husky
is installed via npm
but not yarn
whereas uninstalling the hooks works for both tools. Similar to #81
Current Behaviour
Install
$ yarn add husky@0.15.0-rc.3 -D
arn add v1.4.0
[1/4] ๐ Resolving packages...
[2/4] ๐ Fetching packages...
[3/4] ๐ Linking dependencies...
[4/4] ๐ Building fresh packages...
success Saved lockfile.
success Saved 5 new dependencies.
โโ ci-info@1.1.2
โโ husky@0.14.3
โโ is-ci@1.1.0
โโ normalize-path@1.0.0
โโ strip-indent@2.0.0
โจ Done in 3.13s.
and npm
$ npm i husky@0.15.0-rc.3 --save-dev
...
> husky@0.15.0-rc.3 postinstall /Users/abc/Development/project/node_modules/husky
> node lib/installer/bin install
husky > setting up git hooks
husky > done
+ husky@0.15.0-rc.3
added 8 packages, removed 575 packages and updated 47 packages in 8.268s
Uninstall
$ yarn remove husky
yarn remove v1.4.0
[1/2] Removing module husky...
$ node ./bin/uninstall.js
husky
uninstalling Git hooks
done
$ node ./bin/uninstall.js
husky
uninstalling Git hooks
done
[2/2] Regenerating lockfile and installing missing dependencies...
success Uninstalled packages.
โจ Done in 2.83s.
and npm
$ npm un husky --save-dev
> husky@0.15.0-rc.3 preuninstall /Users/abc/Development/project/node_modules/husky
> node lib/installer/bin uninstall
husky > uninstalling git hooks
husky > done
added 483 packages, removed 14 packages and updated 22 packages in 18.134s
Expected Behaviour
yarn add husky@0.15.0-rc.3 -D
should also trigger the install of the git hooks.
Please mention your node.js, yarn and operating system version.
OS: macOS High Sierra 10.13.3 yarn: v1.4.0 node: v9.4.0 npm: 5.6.0
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 14
- Comments: 20 (4 by maintainers)
Iโm experiencing this with husky v3.0.1 Had to use https://github.com/typicode/husky/issues/227#issuecomment-361779926
@mavogel thanks for the detailed issue ๐ thatโs super helpful ๐ Iโm not getting this issue with
yarn
v1.3.2
, so not sure if itโs related tohusky
install script. Iโll have to try withyarn
v1.4.0
.@fernandopasik https://github.com/typicode/husky/pull/126 could have but not really ๐ The PR is only for picking between
npm
oryarn
when running apackage.json
script (for example, it would runprecommit
withyarn precommit
ornpm run precommit
depending on which one is installed) and wouldnโt have any effect during husky installation.Meanwhile, as a temporary workaround, you can manually run
node node_modules/husky/lib/installer/bin install
or add it to yourpackage.json
:One word of caution, use the
postinstall
hook only if youโre not publishing your project on npm, else your users will get errors when trying to install your module.Same here ! Could we please re-open this issue ?
husky: 3.1.0 node: 12.10.0 (via nvm) yarn: 1.19.2 npm: 6.13.0
It does not install hooks on
yarn add
butnpm install
does@typicode FWIW Iโm using
v1.3.2
:I had the same problem and I fixed it upgrading git.
Installing Husky didnโt create the hooks.
I tried running the script directly:
And got this:
I guessed that during the installation this error was hidden among all the logs and I didnโt see it.
After updating git, I removed node_modules and run
yarn install
again. Everything worked.I hope this helps ๐
experiencing this with husky: 3.0.9 node: 12.2.0 (via nvm) yarn: 1.19.1 yarn workspaces
โ๏ธ does not create the git hooks, confirmed via
ls -l .git/hooks
Manually running huskyโs bin install script does work though https://github.com/typicode/husky/issues/227#issuecomment-361779926
Iโve published a new version if you want to give another try (just run
yarn add husky@next --dev
). Iโve movedv0.15
install script frompostinstall
toinstall
(as it is inv0.14
).