Skip to content

"postinstall" script is executed by consumers of published packages #1

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

Closed
sondreb opened this issue Sep 13, 2021 · 2 comments
Closed

Comments

@sondreb
Copy link

sondreb commented Sep 13, 2021

Using this template will publish a package.json that contains the following script:

"postinstall": "husky install",

This will also run when the published package is consumed.

Not sure if there is a step I'm missing, or if this is an fault with the template?

@tomchen
Copy link
Owner

tomchen commented Sep 13, 2021

I always use yarn 1. It appears yarn 2 is a little different. From husky docs, section yarn 2:

If your package is not private and you're publishing it on a registry like npmjs.com, you need to disable postinstall script using pinst. Otherwise, postinstall will run when someone installs your package and result in an error.

Use pinst in your package to make husky dev only.

I'll update the template and the readme.

tomchen added a commit that referenced this issue Sep 15, 2021
@tomchen
Copy link
Owner

tomchen commented Sep 15, 2021

It had error when being installed no matter user uses yarn 1 or 2+ or npm.

Now after 8887dc8 where I installed pinst, everything is fine. I tested the installation of the package with npm, yarn v1 and yarn v2+, in ubuntu, win and node 12, 14, 16.

@tomchen tomchen closed this as completed Sep 26, 2021
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

2 participants