Skip to content

Clarify Yarn not supporting prepare - #1371

Open
AlecRust wants to merge 1 commit into
typicode:mainfrom
AlecRust:patch-1
Open

Clarify Yarn not supporting prepare#1371
AlecRust wants to merge 1 commit into
typicode:mainfrom
AlecRust:patch-1

Conversation

@AlecRust

Copy link
Copy Markdown

It seems only Yarn v2 (and above) don't support prepare. Yarn Classic i.e. v1, does.

As such it seems "manual setup if using Yarn" should only be recommended if not using Yarn Classic.

In my testing with Yarn Classic, yarn husky init works fine, as does the prepare step in package.json.

It seems only Yarn v2 and above don't support `prepare`. Yarn Classic does.
@st0w

st0w commented Feb 3, 2024

Copy link
Copy Markdown

To add to this discussion regarding Yarn - the documentation contradicts itself and is thus unhelpful.

On the manual setup (https://typicode.github.io/husky/how-to.html#manual-setup) with yarn selected, the first part suggests things to add to package.json and the first comment says Yarn doesn't support prepare script. The very next step is Run prepare once: yarn run prepare.

How does that make sense? What is the proper way to setup Husky with Yarn?

@typicode

typicode commented Feb 3, 2024

Copy link
Copy Markdown
Owner

it's a mistake, yarn is enough to trigger the postinstall script there:
https://typicode.github.io/husky/how-to.html#manual-setup

@chrisEff

chrisEff commented Apr 29, 2024

Copy link
Copy Markdown

@typicode I think you're missing the point here.
Husky is still using prepare (in auto install and it also recommends it in manual install), while Yarn versions >+ 2.0 don't support prepare anymore. Husky should use postinstall instead.

@elvinristi

Copy link
Copy Markdown

Husky is still using prepare (in auto install and it also recommends it in manual install), while Yarn versions >+ 2.0 don't support prepare anymore. Husky should use postinstall instead.

Using postinstall in module which is published as library, has an issue with that. If you install the library in the project, then it will also trigger postinstall of that, so you might get exit code 127 during the yarn install

Trying now to use [ "${HUSKY:-1}" = 0 ] && exit 0; command husky 2>/dev/null && husky (on *nix based )

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 this pull request may close these issues.

5 participants