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

Document that it is not safe to run pinst in the prepack step #24

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

djcsdy
Copy link

@djcsdy djcsdy commented Dec 20, 2024

As much discussed in other issues, "prepack": "pinst --disable" has never worked as intended. It always results in wrong information going into the npm database. It's just that most tools ignored the wrong information, including npm before npm v10.4.0. See https://gist.github.com/djcsdy/3ca078e23fdac4c50e077c84e8284a95

A lot of projects are starting to get hit by this problem:

I assume this is just the tip of the iceberg. EVERY historical package that has been published using pinst in the recommended configuration is broken and cannot be installed correctly by npm >= 10.4. This problem is NOT limited to packages that were published recently.

I am seeing a lot of confusion about the underlying cause, which is not really surprising.

I think the only responsible course of action is to immediately stop recommending that developers use pinst in their prepack and postpack scripts since this results in broken packages and always has done.

Unfortunately the only safe way I know of to run pinst is to run it BEFORE yarn publish. There's no safe way I know of to cause yarn publish to run pinst --disable automatically. It's unfortunate that the solution is so unergonomic, but the only alternative is many broken packages.

Fixes #22, #23.

@JoelLefkowitz
Copy link

Ohhh I've started seeing this in my packages too. @djcsdy your gist really helped clarify things for me: https://gist.github.com/djcsdy/3ca078e23fdac4c50e077c84e8284a95.

I like your suggestion of invoking pinst at release time:

yarn pinst --disable
yarn publish
yarn pinst --enable

Rather than at install time:

{
  "prepack": "pinst --disable",
  "postpack": "pinst --enable"
}

This is because manipulating the scripts is really a 'release' task. Also the npm scripts section is always cluttered so this frees up some space.

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.

npm running _postinstall!?!??!
2 participants