Skip to content
This repository has been archived by the owner on Jul 3, 2023. It is now read-only.

Run husky install as prepare script #221

Open
anatolykazantsev opened this issue May 23, 2023 · 2 comments
Open

Run husky install as prepare script #221

anatolykazantsev opened this issue May 23, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@anatolykazantsev
Copy link

anatolykazantsev commented May 23, 2023

Describe the bug
Yarn tries to run husky install as part of postinstall script when installing this package as a dependency.

To Reproduce

yarn add vue-use-popperjs

Expected behavior

The package being successfully installed.

Screenshots

$ yarn add vue-use-popperjs
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
[1/2] ⠄ vue-demi
error /app/node_modules/vue-use-popperjs: Command failed.
Exit code: 127
Command: husky install
Arguments:
Directory: /app/node_modules/vue-use-popperjs
Output:
/bin/sh: husky: not found

ERROR: 127

Desktop:

  • yarn v1.22.17

Additional context

https://docs.npmjs.com/cli/v9/using-npm/scripts#npm-install
postinstall is executed as a part of install by npm and yarn. Husky is a development dependency of this package which might not be true for project where this package is used.

Now Husky project recommends to use prepare script to install hooks. See explanation at https://blog.typicode.com/husky-git-hooks-autoinstall/

@anatolykazantsev anatolykazantsev added the bug Something isn't working label May 23, 2023
@FieldMarshallVague
Copy link

I have the same issue. I downgraded and locked version to 2.3.1, which circumvents it for me (for now).

@anatolykazantsev
Copy link
Author

anatolykazantsev commented May 24, 2023

I tried prepare as the way to setup Husky (cloned this repo, adjusted package.json and pushed dist directory to be able to use it as a dependency) but it looks like it breaks yarn install in our project when it's executed on clean project checkout (no node_modules/) with empty yarn cache.

Some people suggest it's due parallel fetching + git repo as a package source + "prepare" script combination, see yarnpkg/yarn#6312 (comment)

If I run yarn install --network-concurrency 1 then it succeeds. So seems like "concurrency issue" is valid explanation.

Probably prepare script will work if the package installed from the npm registry.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants