husky icon indicating copy to clipboard operation
husky copied to clipboard

how to setting up?

Open jt3k opened this issue 10 years ago • 14 comments

By using readme.md i install husky npm install husky --save-dev then i add precommit and prepush hooks to npm.

Now I try to do commits but hooks not works.

what am I doing wrong?

jt3k avatar Dec 01 '16 23:12 jt3k

Hi @jt3k,

Normally running npm install husky --save-dev should automatically trigger installation script for you (node_modules/husky/bin/install.js).

So, just by setting precommit in package.json you should be good.

That said, one reason that could explain why hooks weren't installed is if ignore-scripts is set to true. To verify could you run:

npm config get ignore-scripts # should be false

typicode avatar Dec 09 '16 00:12 typicode

2016-12-09 10 23 56

it seems the problem is installing via add yarn husky --dev

thanx for help!

jt3k avatar Dec 09 '16 07:12 jt3k

if you have your own precommit in .git/hooks before npm install husky, than precommit scripts could not be triggered. so just delete your own precommit first.

buildAll avatar Feb 26 '17 08:02 buildAll

For some reason the install script didn't trigger for me, so I just ran it manually and it solved the issue: node node_modules/husky/bin/install.js

dpikt avatar May 26 '17 20:05 dpikt

The same thing happened to me, I installed husky via Yarn and the install script did not trigger. I spent way too much time narrowing down the problem and finding this topic.

Maybe consider changing the title to a more representative one, and reopening to fix the installation with Yarn? Or is it more on Yarn's side that a fix must be made?

acidoxee avatar Aug 05 '17 15:08 acidoxee

It takes me so much time.This help me . wowowoo

lcoder avatar Nov 09 '17 06:11 lcoder

I had this issue because a fork of Husky had been installed from one of my dependencies (Yorkie, from vue-cli), and had written to my .git/hooks directory, so Husky hadn't been able to set itself up.

philwolstenholme avatar Mar 06 '18 14:03 philwolstenholme

For people who venture here in the future looking for a quick fix:

yarn add -D husky was the problem for me. Removing node modules and installing everything again fixed it for me.

kartiklad avatar Apr 16 '18 06:04 kartiklad

I have this problem too. husky does not run. so, i installed it manuly, but still failed. because i had own .git/hooks. node node_modules/husky/bin/install.js image

Gpia avatar May 10 '18 12:05 Gpia

Still happens in yarn 1.7, need to run the install script manually

divyanshu013 avatar Jun 09 '18 08:06 divyanshu013

@philwolstenholme husky v1.0.0-rc.8 should fix that, it'll overwrite hooks generated by the fork.

You can always run rm -rf .git/hooks && mkdir .git/hooks, if you don't have personal hooks in it.

@divyanshu013 is it with husky v1.0.0-rc.8?

typicode avatar Jun 09 '18 18:06 typicode

@typicode this is with 0.14.3, didn't realize there was a RC available

divyanshu013 avatar Jun 09 '18 19:06 divyanshu013

You can always run rm -rf .git/hooks && mkdir .git/hooks, if you don't have personal hooks in it.

This worked for me, thank you so much!

seanWLawrence avatar Jan 14 '19 16:01 seanWLawrence

For version 1.3.1 I had to use node node_modules/husky/husky.js install.

webuniverseio avatar May 04 '19 17:05 webuniverseio