Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

husky package post install hook fails on windows #565

Closed
capaj opened this issue Aug 21, 2019 · 5 comments · Fixed by #573
Closed

husky package post install hook fails on windows #565

capaj opened this issue Aug 21, 2019 · 5 comments · Fixed by #573

Comments

@capaj
Copy link

capaj commented Aug 21, 2019

> [email protected] postinstall C:\Users\jspac001\repos\ProductivityHubUI\node_modules\husky
> opencollective-postinstall || true

'opencollective-postinstall' is not recognized as an internal or external command,
operable program or batch file.
'true' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: `opencollective-postinstall || true`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

is what happens on a windows machine.

@typicode
Copy link
Owner

Thanks for the report. I'm not sure why it can't find open-collective. It's defined as a dependency and I've just tried on Windows.

Could you try with a freshly created repo?

git init
npm init -y
npm install husky --save-dev

@emily-curry
Copy link
Contributor

@typicode I'm experiencing this occasionally in a CI environment, where the environment has kept the node modules from the previous installation but the husky version has changed so it's updating.
Clean installs always work fine, but unfortunately this CI environment is out of my control. On windows, there's no true, though. Looking at other popular packages, I believe || exit 0 is a more reliable way to handle this (1, 2), although core-js uses || echo \"ignore\" which is probably reliable as well.

@capaj
Copy link
Author

capaj commented Aug 26, 2019

I confirm that clean installs run fine.

@typicode
Copy link
Owner

@emily-curry thanks a lot for checking the other projects, do you want to make a PR with || exit 0?

@naingaungphyo
Copy link

naingaungphyo commented Mar 17, 2020

Now latest(master) core-js code changed from

|| operator

to

"postinstall": "node -e "try{require('./postinstall')}catch(e){}"".

in package.json

Husky postinstall script should be changed into the same way, because it is causing error in powershell.
The error is the same as this core-js issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants