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

Prepare script seems to trigger husky installation for users of my npm module #981

Closed
ghost opened this issue May 22, 2021 · 2 comments
Closed

Comments

@ghost
Copy link

ghost commented May 22, 2021

I've just pushed a major update for https://github.com/ismay/stylelint-no-unsupported-browser-features to npm. For that module, part of the update was some housekeeping, like updating husky to latest and adding the recommended prepare script.

Now users that are installing my module are having the prepare script triggered, and thus husky trying to install. Which should not happen. It seems that the prepare lifecycle script doesn't distinguish between production and development installations. This makes the prepare lifecycle hook unusable for projects that have to be published as an npm module.

See this issue and the linked issues for context: RJWadley/stylelint-no-unsupported-browser-features#151. I'm still debugging so information is still coming in, but I thought I'd already report it as it could affect a lot of people if the above is correct.

I've reproduced this on node 16.2.0 with npm 7.13.0. To reproduce run:

# This version contains the prepare script and fails on installation as a dep
npm i --save-dev stylelint-no-unsupported-browser-features@5.0.0
# This version does not have the prepare script and installs fine
npm i --save-dev stylelint-no-unsupported-browser-features@5.0.1

It is unclear to me whether this behaviour of the prepare hook is intentional or not (see this issue: npm/cli#2152). However, what is clear is that at the moment this strategy does not seem to be compatible with projects like the above, as this hook should not be triggered for users that are installing the module as a dependency.

@typicode
Copy link
Owner

typicode commented May 24, 2021

It seems like 5.0.0 is using postinstall instead of prepare
https://unpkg.com/browse/stylelint-no-unsupported-browser-features@5.0.0/package.json

Which is why it installs husky.

@ghost
Copy link
Author

ghost commented May 24, 2021

It seems like 5.0.0 is using postinstall instead of prepare
https://unpkg.com/browse/stylelint-no-unsupported-browser-features@5.0.0/package.json

Which is why it installs husky.

Ah yes you're right, I missed that, the prepare script change wasn't part of the release. Ok that's great, then the prepare script is exactly what I need. Thanks!

@ghost ghost closed this as completed May 24, 2021
This issue was closed.
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

No branches or pull requests

1 participant