husky icon indicating copy to clipboard operation
husky copied to clipboard

Husky doesn't execute post install

Open LordKenzo opened this issue 6 years ago • 13 comments

Hi,

I tried Husky with Node v.15.xx.xx and it doesn't execute post install after launch:

npm i -D husky

added 47 packages, and audited 47 packages in 6s

5 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

while with Node v.14.xx.xx I can install Husky without any problems.

 npm i -D husky

> [email protected] install D:\dev\typescript\huskytemp\node_modules\husky
> node husky install

husky > Setting up git hooks
husky > Done

> [email protected] postinstall D:\dev\typescript\huskytemp\node_modules\husky
> opencollective-postinstall || exit 0

Thank you for using husky!
If you rely on this package, please consider supporting our open collective:
> https://opencollective.com/husky/donate

npm WARN [email protected] No description
npm WARN [email protected] No repository field.

+ [email protected]
added 47 packages from 21 contributors and audited 47 packages in 5.974s

5 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

Anyone got this problem?

I'm on Windows.

LordKenzo avatar Nov 10 '20 14:11 LordKenzo

facing exactly the same issue, I was going crazy! works with previous node versions, the issues seems to be only with v15

janmarcano avatar Nov 12 '20 14:11 janmarcano

Appears to be an issue with v14.13.0 as well

whardier avatar Nov 19 '20 22:11 whardier

I think it's related to npm v7, I'd suggest using npm v6 until v7 becomes @latest version.

Alternatively it seems like husky v5 doesn't have this issue with postinstall script.

typicode avatar Nov 22 '20 04:11 typicode

I can confirm the difference is npm 6 vs 7, regardless of node version.

Possibly related:

  • https://github.com/npm/cli/issues/1905
  • https://github.com/npm/cli/issues/2194

thesmiley1 avatar Nov 22 '20 20:11 thesmiley1

npm v7 has intentionally suppressed all postinstall output, to avoid spam. Generally, postinstall is meant only for compilation, and not for husky’s automatic security-bypassing hook-installing behavior - I’m not sure what workarounds for you exist.

ljharb avatar Nov 27 '20 17:11 ljharb

npm v7 has intentionally suppressed all postinstall output, to avoid spam. Generally, postinstall is meant only for compilation, and not for husky’s automatic security-bypassing hook-installing behavior - I’m not sure what workarounds for you exist.

Suppressing output is quite different from suppressing execution.

thesmiley1 avatar Nov 28 '20 20:11 thesmiley1

Indeed; postinstall scripts should still execute as far as I’m aware, you just won’t see any output from them unless they fail.

ljharb avatar Nov 29 '20 02:11 ljharb

Is there any workaround available (e.g. manually specifying a postinstall in my repo package.json)?

I tried v5 and it works but I cannot use it right now because of its license.

pitasi avatar Nov 30 '20 09:11 pitasi

The issue is INIT_CWD not being set anymore: https://github.com/npm/cli/issues/2033

Also this is a duplicate of #776

d-fischer avatar Dec 03 '20 13:12 d-fischer

The issue is INIT_CWD not being set anymore: npm/cli#2033

Yes, thanks! Meanwhile, INIT_CWD could be manually set:

INIT_CWD="$(pwd)" npm install husky --save-dev

typicode avatar Dec 05 '20 11:12 typicode

or possibly use require.resolve?

On Sat, Dec 5, 2020 at 2:37 AM typicode [email protected] wrote:

The issue is INIT_CWD not being set anymore: npm/cli#2033 https://github.com/npm/cli/issues/2033

Yes, thanks! Meanwhile, INIT_CWD could be manually set:

INIT_CWD="$(pwd)" npm install husky --save-dev

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/typicode/husky/issues/788#issuecomment-739239479, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACKRFIQ73X4MJ2I7ZP5RWDSTILNVANCNFSM4TQXWIVA .

--

[image: --]

Shane R. Spencer [image: https://]about.me/ShaneSpencer https://about.me/ShaneSpencer?promo=email_sig

whardier avatar Dec 05 '20 16:12 whardier

This should be resolved now in npm v7.1.2. I've run some tests locally using npm i and npm ci, and hooks were installed with both.

ghost avatar Dec 11 '20 22:12 ghost

This should be resolved now in npm v7.1.2. I've run some tests locally using npm i and npm ci, and hooks were installed with both.

Awesome :)

typicode avatar Dec 11 '20 23:12 typicode